From ccf7aab16bbc610c7289253aeb3d6ff87f938df7 Mon Sep 17 00:00:00 2001 From: Niklas Cathor Date: Thu, 1 Aug 2013 03:25:16 +0200 Subject: [PATCH] implemented DELETE --- src/main.c | 3 ++- src/operations.c | 6 +++++- src/remote.c | 9 +++++++-- src/remotestorage-fuse.h | 4 +++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 22b38cd..aaec830 100644 --- a/src/main.c +++ b/src/main.c @@ -11,7 +11,8 @@ static struct fuse_operations rs_ops = { .mkdir = rs_mkdir, .rmdir = rs_rmdir, .flush = rs_flush, - .create = rs_create + .create = rs_create, + .unlink = rs_unlink }; static struct fuse_opt rs_opts[] = { diff --git a/src/operations.c b/src/operations.c index 647a05e..6fee227 100644 --- a/src/operations.c +++ b/src/operations.c @@ -163,6 +163,10 @@ int rs_flush(const char *path, struct fuse_file_info *fi) { return 0; } -int rs_create (const char *path, mode_t mode, struct fuse_file_info *fi) { +int rs_create(const char *path, mode_t mode, struct fuse_file_info *fi) { return rs_truncate(path, 0); } + +int rs_unlink(const char *path) { + return delete_node_remote(path); +} diff --git a/src/remote.c b/src/remote.c index 9f890f2..69002b0 100644 --- a/src/remote.c +++ b/src/remote.c @@ -113,8 +113,8 @@ long perform_request(enum rs_method method, const char *path, struct rs_node* no log_msg("PUTting %d bytes", node->size); break; case DELETE: - log_msg("DELETE NOT IMPLEMENTED!!!"); - return -1; + curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE"); + break; } static char errorbuf[CURL_ERROR_SIZE]; @@ -197,3 +197,8 @@ int put_node_remote(const char *path, struct rs_node *node) { long status = perform_request(PUT, path, node); return (status == 200 || status == 201) ? 0 : status; } + +int delete_node_remote(const char *path) { + long status = perform_request(DELETE, path, NULL); + return status == 200 ? 0 : status; +} diff --git a/src/remotestorage-fuse.h b/src/remotestorage-fuse.h index 9615e6c..6ff34a6 100644 --- a/src/remotestorage-fuse.h +++ b/src/remotestorage-fuse.h @@ -48,7 +48,8 @@ int rs_write(const char *path, const char *buf, size_t size, off_t offset, int rs_mkdir(const char *path, mode_t mode); int rs_rmdir(const char *path); int rs_flush(const char *path, struct fuse_file_info *fi); -int rs_create (const char *path, mode_t mode, struct fuse_file_info *fi); +int rs_create(const char *path, mode_t mode, struct fuse_file_info *fi); +int rs_unlink(const char *path); /* clutter */ @@ -111,6 +112,7 @@ void cleanup_remote(); struct rs_node *get_node_remote(const char *path, bool fetch_body); struct rs_node *get_node_remote_via_parent(const char *path, bool fetch_body); int put_node_remote(const char *path, struct rs_node *node); +int delete_node_remote(const char *path); /* TRIE */