Untested delete file function is added
This commit is contained in:
1 parent
157105952b
commit
3a93537cbd
4 files changed
+17
-24
No files matched your search
@@ -34,7 +34,7 @@ int create_file_system(char* disk_name, char* hdd_or_partition, uint64_t filesys
|
|||||||
int lsfs_disk_create_entry(const char* path, Table_Entry_Kind entry_kind);
|
int lsfs_disk_create_entry(const char* path, Table_Entry_Kind entry_kind);
|
||||||
Directory_Table* lsfs_find_directory(const char* path, bool drop_filename);
|
Directory_Table* lsfs_find_directory(const char* path, bool drop_filename);
|
||||||
int lsfs_disk_getattr(lsfs_file* find_file, const char *path);
|
int lsfs_disk_getattr(lsfs_file* find_file, const char *path);
|
||||||
int lsfs_disk_delete_file(lsfs_file_id file_id);
|
int lsfs_disk_delete_file(lsfs_file *file);
|
||||||
int get_free_sectors_table();
|
int get_free_sectors_table();
|
||||||
int get_free_sectors(int num_sectors_needed, lsfs_sector_offset* output_array);
|
int get_free_sectors(int num_sectors_needed, lsfs_sector_offset* output_array);
|
||||||
int lsfs_disk_read_data_from_file(lsfs_file* file, int buffer_size, void* buffer_for_data);
|
int lsfs_disk_read_data_from_file(lsfs_file* file, int buffer_size, void* buffer_for_data);
|
||||||
@@ -368,15 +368,12 @@ int lsfs_disk_rename_file(lsfs_file* file, const char* new_filename) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsfs_disk_delete_file(lsfs_file_id file_id) {
|
int lsfs_disk_delete_file(lsfs_file *file) {
|
||||||
mif* mif_record = calloc(1, SECTOR_SIZE);
|
Table_Entry *zero_buffer = calloc(1, (DEFAULT_ENTRY_SIZE * SECTOR_SIZE));
|
||||||
read_data_from_disk(file_id, 1, mif_record);
|
//read_data_from_disk(file_id, 1, mif_record);
|
||||||
|
write_data_to_disk(file->table_entry_sector_index, DEFAULT_TABLE_SIZE, zero_buffer);
|
||||||
|
|
||||||
|
free(zero_buffer);
|
||||||
// TODO Delete/free all data sectors.
|
|
||||||
// Delete/free the mif record sector.
|
|
||||||
|
|
||||||
free(mif_record);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-15
@@ -59,7 +59,11 @@ int lsfs_rmdir(const char *path) {
|
|||||||
|
|
||||||
int lsfs_unlink(const char *path) {
|
int lsfs_unlink(const char *path) {
|
||||||
|
|
||||||
// remove / delete a file
|
lsfs_file *found_file = calloc(1, sizeof(lsfs_file));
|
||||||
|
|
||||||
|
lsfs_disk_getattr(found_file, path);
|
||||||
|
lsfs_disk_delete_file(found_file);
|
||||||
|
free(found_file);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -126,21 +130,13 @@ int lsfs_getattr( const char *path, struct stat *stbuf ) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lsfs_write(const char *path, const char *content, size_t content_length, off_t offset_to_next_entry, struct fuse_file_info *file_info) {
|
int lsfs_write(const char *path, const char *content, size_t content_length, off_t offset_to_next_entry, struct fuse_file_info *file_info)
|
||||||
//(void) offset_to_next_entry;
|
{
|
||||||
//(void) file_info;
|
int res = lsfs_disk_write_data_to_file(
|
||||||
int res;
|
((lsfs_file*) file_info->fh),
|
||||||
//printf("WRITE: offset id: %d\n", offset_to_next_entry);
|
content_length,
|
||||||
// printf("read: (path=%s)\n", path);
|
(void*) content, offset_to_next_entry);
|
||||||
|
|
||||||
//time_t current_time;
|
|
||||||
//time ( ¤t_time );
|
|
||||||
|
|
||||||
res = lsfs_disk_write_data_to_file(((lsfs_file*) file_info->fh), content_length, (void*) content, offset_to_next_entry);
|
|
||||||
|
|
||||||
//((lsfs_file*) file_info->fh)->size += res;
|
|
||||||
//((lsfs_file*) file_info->fh)->access_time = current_time;
|
|
||||||
//((lsfs_file*) file_info->fh)->modification_time = current_time;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
Reference in new issue
Block a user