mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 21:24:28 -08:00
fuse: add unlink to remove files
This commit is contained in:
@@ -63,6 +63,7 @@ static struct fuse_operations mediafirefs_oper = {
|
|||||||
.open = mediafirefs_open,
|
.open = mediafirefs_open,
|
||||||
.read = mediafirefs_read,
|
.read = mediafirefs_read,
|
||||||
.release = mediafirefs_release,
|
.release = mediafirefs_release,
|
||||||
|
.unlink = mediafirefs_unlink,
|
||||||
/* .create = mediafirefs_create,
|
/* .create = mediafirefs_create,
|
||||||
.fsync = mediafirefs_fsync,
|
.fsync = mediafirefs_fsync,
|
||||||
.getxattr = mediafirefs_getxattr,
|
.getxattr = mediafirefs_getxattr,
|
||||||
@@ -73,7 +74,6 @@ static struct fuse_operations mediafirefs_oper = {
|
|||||||
.setxattr = mediafirefs_setxattr,
|
.setxattr = mediafirefs_setxattr,
|
||||||
.statfs = mediafirefs_statfs,
|
.statfs = mediafirefs_statfs,
|
||||||
.truncate = mediafirefs_truncate,
|
.truncate = mediafirefs_truncate,
|
||||||
.unlink = mediafirefs_unlink,
|
|
||||||
.utime = mediafirefs_utime,
|
.utime = mediafirefs_utime,
|
||||||
.write = mediafirefs_write,*/
|
.write = mediafirefs_write,*/
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -241,6 +241,42 @@ int mediafirefs_rmdir(const char *path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mediafirefs_unlink(const char *path)
|
||||||
|
{
|
||||||
|
const char *key;
|
||||||
|
int retval;
|
||||||
|
struct mediafirefs_context_private *ctx;
|
||||||
|
|
||||||
|
ctx = fuse_get_context()->private_data;
|
||||||
|
|
||||||
|
/* no need to check
|
||||||
|
* - if path is directory
|
||||||
|
* - if directory is empty
|
||||||
|
* - if directory is root
|
||||||
|
*
|
||||||
|
* because getattr was called before and already made sure
|
||||||
|
*/
|
||||||
|
|
||||||
|
key = folder_tree_path_get_key(ctx->tree, ctx->conn, path);
|
||||||
|
if (key == NULL) {
|
||||||
|
fprintf(stderr, "key is NULL\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = mfconn_api_file_delete(ctx->conn, key);
|
||||||
|
mfconn_update_secret_key(ctx->conn);
|
||||||
|
if (retval != 0) {
|
||||||
|
fprintf(stderr, "mfconn_api_file_create unsuccessful\n");
|
||||||
|
// FIXME: find better errno in this case
|
||||||
|
return -EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* retrieve remote changes to not get out of sync */
|
||||||
|
folder_tree_update(ctx->tree, ctx->conn);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mediafirefs_open(const char *path, struct fuse_file_info *file_info)
|
int mediafirefs_open(const char *path, struct fuse_file_info *file_info)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ int mediafirefs_readdir(const char *path, void *buf,
|
|||||||
void mediafirefs_destroy();
|
void mediafirefs_destroy();
|
||||||
int mediafirefs_mkdir(const char *path, mode_t mode);
|
int mediafirefs_mkdir(const char *path, mode_t mode);
|
||||||
int mediafirefs_rmdir(const char *path);
|
int mediafirefs_rmdir(const char *path);
|
||||||
|
int mediafirefs_unlink(const char *path);
|
||||||
int mediafirefs_open(const char *path,
|
int mediafirefs_open(const char *path,
|
||||||
struct fuse_file_info *file_info);
|
struct fuse_file_info *file_info);
|
||||||
int mediafirefs_read(const char *path, char *buf, size_t size,
|
int mediafirefs_read(const char *path, char *buf, size_t size,
|
||||||
|
|||||||
Reference in New Issue
Block a user