[gnome-commander] Return true of false when doing chmod and use this value elsewhere
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Return true of false when doing chmod and use this value elsewhere
- Date: Sun, 30 May 2021 17:28:11 +0000 (UTC)
commit d174b271934b7328973493b9235c02f3275dbd71
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun May 30 19:27:27 2021 +0200
Return true of false when doing chmod and use this value elsewhere
src/dialogs/gnome-cmd-chmod-dialog.cc | 7 ++++++-
src/dialogs/gnome-cmd-file-props-dialog.cc | 4 ++--
src/gnome-cmd-file-list.cc | 5 ++++-
src/gnome-cmd-file.cc | 21 ++++++++++++++++++---
src/gnome-cmd-file.h | 2 +-
5 files changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-chmod-dialog.cc b/src/dialogs/gnome-cmd-chmod-dialog.cc
index a16308c14..edd1d52cd 100644
--- a/src/dialogs/gnome-cmd-chmod-dialog.cc
+++ b/src/dialogs/gnome-cmd-chmod-dialog.cc
@@ -69,10 +69,15 @@ static void do_chmod (GnomeCmdFile *in, guint32 permissions, gboolean recursive,
&& mode == CHMOD_DIRS_ONLY
&& in->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY))
{
- in->chmod(permissions);
+ if (!in->chmod(permissions))
+ {
+ return;
+ }
if (!recursive)
+ {
return;
+ }
}
if (in->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
diff --git a/src/dialogs/gnome-cmd-file-props-dialog.cc b/src/dialogs/gnome-cmd-file-props-dialog.cc
index ddb7e5e83..925d3b18e 100644
--- a/src/dialogs/gnome-cmd-file-props-dialog.cc
+++ b/src/dialogs/gnome-cmd-file-props-dialog.cc
@@ -205,10 +205,10 @@ static void on_dialog_ok (GtkButton *btn, GnomeCmdFilePropsDialogPrivate *data)
auto perms = gnome_cmd_chmod_component_get_perms (GNOME_CMD_CHMOD_COMPONENT (data->chmod_component));
if (perms != GetGfileAttributeUInt32(data->f->gFile, G_FILE_ATTRIBUTE_UNIX_MODE) & 0xFFF )
- data->f->chmod(perms);
+ retValue = data->f->chmod(perms);
}
- if (result == GNOME_VFS_OK)
+ if (result == GNOME_VFS_OK && retValue)
{
uid_t uid = gnome_cmd_chown_component_get_owner (GNOME_CMD_CHOWN_COMPONENT (data->chown_component));
gid_t gid = gnome_cmd_chown_component_get_group (GNOME_CMD_CHOWN_COMPONENT (data->chown_component));
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index fb097a5c3..8f8bcbfdc 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1280,7 +1280,10 @@ static void mime_exec_single (GnomeCmdFile *f)
return;
}
- f->chmod(GetGfileAttributeUInt32(f->gFile, G_FILE_ATTRIBUTE_UNIX_MODE) |
GNOME_CMD_PERM_USER_EXEC);
+ if(!f->chmod(GetGfileAttributeUInt32(f->gFile, G_FILE_ATTRIBUTE_UNIX_MODE) |
GNOME_CMD_PERM_USER_EXEC))
+ {
+ return;
+ }
}
}
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index f4661a2c8..1509ca100 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -344,7 +344,7 @@ void GnomeCmdFile::unref()
}
-void GnomeCmdFile::chmod(guint32 permissions)
+gboolean GnomeCmdFile::chmod(guint32 permissions)
{
GError *error;
error = nullptr;
@@ -357,8 +357,15 @@ void GnomeCmdFile::chmod(guint32 permissions)
if (error)
{
g_message ("chmod: retrieving file info failed: %s", error->message);
+
+ gchar *fname = GetGfileAttributeString(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ gchar *msg = g_strdup_printf (_("Could not chmod %s"), fname);
+ gnome_cmd_show_message (*main_win, msg, error->message);
+ g_free (msg);
+ g_free (fname);
+
g_error_free (error);
- return;
+ return false;
}
g_file_info_set_attribute_uint32(gFileInfoPerms,
@@ -373,9 +380,16 @@ void GnomeCmdFile::chmod(guint32 permissions)
if (error)
{
g_message ("chmod: setting file mode failed: %s", error->message);
+
+ gchar *fname = GetGfileAttributeString(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ gchar *msg = g_strdup_printf (_("Could not chmod %s"), fname);
+ gnome_cmd_show_message (*main_win, msg, error->message);
+ g_free (msg);
+ g_free (fname);
+
g_object_unref(gFileInfoPerms);
g_error_free (error);
- return;
+ return false;
}
g_object_unref(gFileInfoPerms);
@@ -387,6 +401,7 @@ void GnomeCmdFile::chmod(guint32 permissions)
gnome_cmd_dir_file_changed (dir, uri_str);
g_free (uri_str);
}
+ return true;
}
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index 7a823e05f..416f149df 100644
--- a/src/gnome-cmd-file.h
+++ b/src/gnome-cmd-file.h
@@ -90,7 +90,7 @@ struct GnomeCmdFile
const gchar *get_type_string();
gboolean get_type_pixmap_and_mask(GdkPixmap **pixmap, GdkBitmap **mask);
- void chmod(guint32 permissions);
+ gboolean chmod(guint32 permissions);
gboolean chown(uid_t uid, gid_t gid);
GnomeVFSResult rename(const gchar *new_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]