common: Add XDG_APP_CP_FLAGS_MOVE support

This commit is contained in:
Alexander Larsson
2016-02-18 17:31:43 +01:00
parent abdbb17a72
commit 6428fcce45
2 changed files with 19 additions and 4 deletions

View File

@@ -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)

View File

@@ -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,