diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-02-18 17:31:43 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-02-18 17:31:43 +0100 |
commit | 6428fcce458b3485291ef4ca6d2aaeaa868d8490 (patch) | |
tree | 72c617e7b29263319504d7a6d2112f953ed8e27c | |
parent | abdbb17a724112d268ebc160aa6dfaadcd94eb22 (diff) | |
download | xdg-app-6428fcce458b3485291ef4ca6d2aaeaa868d8490.tar.gz |
common: Add XDG_APP_CP_FLAGS_MOVE support
-rw-r--r-- | common/xdg-app-utils.c | 20 | ||||
-rw-r--r-- | common/xdg-app-utils.h | 3 |
2 files changed, 19 insertions, 4 deletions
diff --git a/common/xdg-app-utils.c b/common/xdg-app-utils.c index 8b2f804..4e5a677 100644 --- a/common/xdg-app-utils.c +++ b/common/xdg-app-utils.c @@ -1304,6 +1304,7 @@ xdg_app_cp_a (GFile *src, int dest_dfd = -1; gboolean merge = (flags & XDG_APP_CP_FLAGS_MERGE) != 0; gboolean no_chown = (flags & XDG_APP_CP_FLAGS_NO_CHOWN) != 0; + gboolean move = (flags & XDG_APP_CP_FLAGS_MOVE) != 0; int r; enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::uid,unix::gid,unix::mode", @@ -1384,12 +1385,25 @@ xdg_app_cp_a (GFile *src, GFileCopyFlags copyflags = G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS; if (!no_chown) copyflags |= G_FILE_COPY_ALL_METADATA; - if (!g_file_copy (src_child, dest_child, copyflags, - cancellable, NULL, NULL, error)) - goto out; + if (move) + { + if (!g_file_move (src_child, dest_child, copyflags, + cancellable, NULL, NULL, error)) + goto out; + } + else + { + if (!g_file_copy (src_child, dest_child, copyflags, + cancellable, NULL, NULL, error)) + goto out; + } } } + if (move && + !g_file_delete (src, NULL, error)) + goto out; + ret = TRUE; out: if (dest_dfd != -1) diff --git a/common/xdg-app-utils.h b/common/xdg-app-utils.h index de5ed79..62c7f4d 100644 --- a/common/xdg-app-utils.h +++ b/common/xdg-app-utils.h @@ -206,7 +206,8 @@ gboolean xdg_app_spawn (GFile *dir, typedef enum { XDG_APP_CP_FLAGS_NONE = 0, XDG_APP_CP_FLAGS_MERGE = 1<<0, - XDG_APP_CP_FLAGS_NO_CHOWN = 1<<1 + XDG_APP_CP_FLAGS_NO_CHOWN = 1<<1, + XDG_APP_CP_FLAGS_MOVE = 1<<2, } XdgAppCpFlags; gboolean xdg_app_cp_a (GFile *src, |