mufs: implement mufs_unlink()
This commit is contained in:
parent
d6fa387868
commit
65c1fc28d3
2 changed files with 18 additions and 0 deletions
|
@ -56,3 +56,4 @@ void mufs_close(struct mufs_file *file);
|
|||
long mufs_seek(struct mufs_file *file, long offset, int whence);
|
||||
size_t mufs_read(struct mufs_file *file, void *data, size_t len);
|
||||
size_t mufs_write(struct mufs_file *file, const void *data, size_t len);
|
||||
int mufs_unlink(struct mufs *fs, const char *path);
|
||||
|
|
|
@ -116,3 +116,20 @@ size_t mufs_write(struct mufs_file *file, const void *data, size_t len)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mufs_unlink(struct mufs *fs, const char *path)
|
||||
{
|
||||
struct mufs_stat stat;
|
||||
struct mufs_tree *tree;
|
||||
|
||||
if (!(tree = resolve_path(fs, path, &stat)))
|
||||
return -1;
|
||||
|
||||
if (stat.type != MUFS_FILE)
|
||||
return -1;
|
||||
|
||||
if (mufs_shrink_tree(tree, 0) < 0)
|
||||
return -1;
|
||||
|
||||
return mufs_rmpath(fs, path);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue