mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
gio-tool: Add a --default-permissions argument to gio copy
This sets the `G_FILE_COPY_DEFAULT_PERMS` flag on the operation, creating the copied file with default permissions rather than the same permissions as the source file. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #174
This commit is contained in:
@@ -226,6 +226,10 @@
|
|||||||
<term><option>-P</option>, <option>--no-dereference</option></term>
|
<term><option>-P</option>, <option>--no-dereference</option></term>
|
||||||
<listitem><para>Never follow symbolic links.</para></listitem>
|
<listitem><para>Never follow symbolic links.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--default-permissions</option></term>
|
||||||
|
<listitem><para>Use the default permissions of the current process for the destination file, rather than copying the permissions of the source file.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect3>
|
</refsect3>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@@ -37,6 +37,7 @@ static gboolean interactive = FALSE;
|
|||||||
static gboolean preserve = FALSE;
|
static gboolean preserve = FALSE;
|
||||||
static gboolean backup = FALSE;
|
static gboolean backup = FALSE;
|
||||||
static gboolean no_dereference = FALSE;
|
static gboolean no_dereference = FALSE;
|
||||||
|
static gboolean default_permissions = FALSE;
|
||||||
|
|
||||||
static const GOptionEntry entries[] = {
|
static const GOptionEntry entries[] = {
|
||||||
{ "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, N_("No target directory"), NULL },
|
{ "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, N_("No target directory"), NULL },
|
||||||
@@ -45,6 +46,7 @@ static const GOptionEntry entries[] = {
|
|||||||
{ "preserve", 'p', 0, G_OPTION_ARG_NONE, &preserve, N_("Preserve all attributes"), NULL },
|
{ "preserve", 'p', 0, G_OPTION_ARG_NONE, &preserve, N_("Preserve all attributes"), NULL },
|
||||||
{ "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("Backup existing destination files"), NULL },
|
{ "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, N_("Backup existing destination files"), NULL },
|
||||||
{ "no-dereference", 'P', 0, G_OPTION_ARG_NONE, &no_dereference, N_("Never follow symbolic links"), NULL },
|
{ "no-dereference", 'P', 0, G_OPTION_ARG_NONE, &no_dereference, N_("Never follow symbolic links"), NULL },
|
||||||
|
{ "default-permissions", 0, 0, G_OPTION_ARG_NONE, &default_permissions, N_("Use default permissions for the destination"), NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,6 +177,8 @@ handle_copy (int argc, char *argv[], gboolean do_help)
|
|||||||
flags |= G_FILE_COPY_NOFOLLOW_SYMLINKS;
|
flags |= G_FILE_COPY_NOFOLLOW_SYMLINKS;
|
||||||
if (preserve)
|
if (preserve)
|
||||||
flags |= G_FILE_COPY_ALL_METADATA;
|
flags |= G_FILE_COPY_ALL_METADATA;
|
||||||
|
if (default_permissions)
|
||||||
|
flags |= G_FILE_COPY_TARGET_DEFAULT_PERMS;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
start_time = g_get_monotonic_time ();
|
start_time = g_get_monotonic_time ();
|
||||||
|
Reference in New Issue
Block a user