[gnome-commander] Propagate the error of the chmod function
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Propagate the error of the chmod function
- Date: Thu, 24 Jun 2021 18:07:23 +0000 (UTC)
commit 815e4a91d46907fe852e854ef266cc55237669e5
Author: Uwe Scholz <u scholz83 gmx de>
Date: Thu Jun 24 18:49:47 2021 +0200
Propagate the error of the chmod function
src/dialogs/gnome-cmd-chmod-dialog.cc | 2 +-
src/dialogs/gnome-cmd-file-props-dialog.cc | 2 +-
src/gnome-cmd-file-list.cc | 2 +-
src/gnome-cmd-file.cc | 30 +++++++++++++++---------------
src/gnome-cmd-file.h | 2 +-
5 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-chmod-dialog.cc b/src/dialogs/gnome-cmd-chmod-dialog.cc
index 7a14d6ca..b5e5deba 100644
--- a/src/dialogs/gnome-cmd-chmod-dialog.cc
+++ b/src/dialogs/gnome-cmd-chmod-dialog.cc
@@ -69,7 +69,7 @@ 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))
{
- if (!in->chmod(permissions))
+ if (!in->chmod(permissions, nullptr))
{
return;
}
diff --git a/src/dialogs/gnome-cmd-file-props-dialog.cc b/src/dialogs/gnome-cmd-file-props-dialog.cc
index e229b95e..5e0fc1b3 100644
--- a/src/dialogs/gnome-cmd-file-props-dialog.cc
+++ b/src/dialogs/gnome-cmd-file-props-dialog.cc
@@ -208,7 +208,7 @@ 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 )
- retValue = data->f->chmod(perms);
+ retValue = data->f->chmod(perms, &error);
}
if (result == GNOME_VFS_OK && retValue)
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 0f048158..fc776f4a 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1280,7 +1280,7 @@ static void mime_exec_single (GnomeCmdFile *f)
return;
}
- if(!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, nullptr))
{
return;
}
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 8ba52618..c44b3849 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -347,30 +347,31 @@ void GnomeCmdFile::unref()
}
-gboolean GnomeCmdFile::chmod(guint32 permissions)
+gboolean GnomeCmdFile::chmod(guint32 permissions, GError **error)
{
- GError *error;
- error = nullptr;
+ GError *tmp_error = nullptr;
auto gFileInfoPerms = g_file_query_info(gFile,
G_FILE_ATTRIBUTE_UNIX_MODE,
G_FILE_QUERY_INFO_NONE,
nullptr,
- &error);
- if (error)
+ &tmp_error);
+ if (tmp_error)
{
- g_message ("chmod: retrieving file info failed: %s", error->message);
+ g_message ("chmod: retrieving file info failed: %s", tmp_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);
+ gnome_cmd_show_message (*main_win, msg, tmp_error->message);
g_free (msg);
g_free (fname);
- g_error_free (error);
+ g_propagate_error (error, tmp_error);
return false;
}
+ tmp_error = nullptr;
+
g_file_info_set_attribute_uint32(gFileInfoPerms,
G_FILE_ATTRIBUTE_UNIX_MODE,
permissions);
@@ -379,19 +380,19 @@ gboolean GnomeCmdFile::chmod(guint32 permissions)
gFileInfoPerms,
G_FILE_QUERY_INFO_NONE,
nullptr,
- &error);
- if (error)
+ &tmp_error);
+ if (tmp_error)
{
- g_message ("chmod: setting file mode failed: %s", error->message);
+ g_message ("chmod: setting file mode failed: %s", tmp_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);
+ gnome_cmd_show_message (*main_win, msg, tmp_error->message);
g_free (msg);
g_free (fname);
g_object_unref(gFileInfoPerms);
- g_error_free (error);
+ g_propagate_error (error, tmp_error);
return false;
}
@@ -412,8 +413,7 @@ gboolean GnomeCmdFile::chown(uid_t uid, gid_t gid, GError **error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- GError *tmp_error;
- tmp_error = nullptr;
+ GError *tmp_error = nullptr;
auto gFileInfoMods = g_file_query_info(gFile,
G_FILE_ATTRIBUTE_UNIX_UID "," G_FILE_ATTRIBUTE_UNIX_GID,
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index 89f8a420..d7664303 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);
- gboolean chmod(guint32 permissions);
+ gboolean chmod(guint32 permissions, GError **error);
gboolean chown(uid_t uid, gid_t gid, GError **error);
GnomeVFSResult rename(const gchar *new_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]