mufs: implement mufs_rmdir()

This commit is contained in:
S.J.R. van Schaik 2017-06-12 15:35:15 +02:00
parent 3b531e868b
commit d6fa387868
2 changed files with 14 additions and 0 deletions

View file

@ -48,6 +48,7 @@ struct mufs_dir *mufs_opendir(struct mufs *fs, const char *path);
void mufs_closedir(struct mufs_dir *dir);
int mufs_readdir(struct mufs_dir *dir, struct mufs_dirent *dirent);
int mufs_mkdir(struct mufs *fs, const char *path);
int mufs_rmdir(struct mufs *fs, const char *path);
int mufs_create(struct mufs *fs, const char *path);
struct mufs_file *mufs_open(struct mufs *fs, const char *path, int mode);

View file

@ -288,3 +288,16 @@ int mufs_mkdir(struct mufs *fs, const char *path)
{
return mufs_mkpath(fs, path, MUFS_DIR);
}
int mufs_rmdir(struct mufs *fs, const char *path)
{
struct mufs_stat stat;
if (mufs_stat(fs, path, &stat) < 0)
return -1;
if (stat.type != MUFS_DIR || stat.file_size != 0)
return -1;
return mufs_rmpath(fs, path);
}