mufs: implement mufs_unlink()

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent d6fa387868
commit 65c1fc28d3
  1. 1
      include/fs/mufs.h
  2. 17
      source/fs/mufs/file.c

@ -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…
Cancel
Save