[gnome-commander] Replace GNOME_VFS_PERM... with own define statements
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Replace GNOME_VFS_PERM... with own define statements
- Date: Fri, 29 Jan 2021 17:21:14 +0000 (UTC)
commit 115f869face84012f17901846476d00a44040aa7
Author: Uwe Scholz <u scholz83 gmx de>
Date: Wed Jan 27 23:13:35 2021 +0100
Replace GNOME_VFS_PERM... with own define statements
src/dialogs/gnome-cmd-mkdir-dialog.cc | 2 +-
src/gnome-cmd-chmod-component.cc | 10 +++----
src/gnome-cmd-con.cc | 6 ++--
src/gnome-cmd-file-list.cc | 2 +-
src/gnome-cmd-file.cc | 10 +++----
src/tags/gnome-cmd-tags-file.cc | 2 +-
src/utils.cc | 52 +++++++++++++++++------------------
src/utils.h | 19 +++++++++++--
8 files changed, 57 insertions(+), 46 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-mkdir-dialog.cc b/src/dialogs/gnome-cmd-mkdir-dialog.cc
index 82ba31c3..da31cb7f 100644
--- a/src/dialogs/gnome-cmd-mkdir-dialog.cc
+++ b/src/dialogs/gnome-cmd-mkdir-dialog.cc
@@ -104,7 +104,7 @@ static void response_callback (GtkDialog *dialog, int response_id, GnomeCmdDir *
// the list of uri's to be created
GSList *uri_list = make_uri_list (dir, filename);
- guint perm = ((GNOME_VFS_PERM_USER_ALL | GNOME_VFS_PERM_GROUP_ALL |
GNOME_VFS_PERM_OTHER_ALL) & ~gnome_cmd_data.umask ) | GNOME_VFS_PERM_USER_WRITE | GNOME_VFS_PERM_USER_EXEC;
+ guint perm = ((GNOME_CMD_PERM_USER_ALL | GNOME_CMD_PERM_GROUP_ALL |
GNOME_CMD_PERM_OTHER_ALL) & ~gnome_cmd_data.umask ) | GNOME_CMD_PERM_USER_WRITE | GNOME_CMD_PERM_USER_EXEC;
for (GSList *i = uri_list; i; i = g_slist_next (i))
{
diff --git a/src/gnome-cmd-chmod-component.cc b/src/gnome-cmd-chmod-component.cc
index a2371a80..51a22663 100644
--- a/src/gnome-cmd-chmod-component.cc
+++ b/src/gnome-cmd-chmod-component.cc
@@ -28,10 +28,10 @@
using namespace std;
-GnomeVFSFilePermissions check_perm[3][3] = {
- {GNOME_VFS_PERM_USER_READ, GNOME_VFS_PERM_USER_WRITE, GNOME_VFS_PERM_USER_EXEC},
- {GNOME_VFS_PERM_GROUP_READ, GNOME_VFS_PERM_GROUP_WRITE, GNOME_VFS_PERM_GROUP_EXEC},
- {GNOME_VFS_PERM_OTHER_READ, GNOME_VFS_PERM_OTHER_WRITE, GNOME_VFS_PERM_OTHER_EXEC}
+guint check_perm[3][3] = {
+ {GNOME_CMD_PERM_USER_READ, GNOME_CMD_PERM_USER_WRITE, GNOME_CMD_PERM_USER_EXEC},
+ {GNOME_CMD_PERM_GROUP_READ, GNOME_CMD_PERM_GROUP_WRITE, GNOME_CMD_PERM_GROUP_EXEC},
+ {GNOME_CMD_PERM_OTHER_READ, GNOME_CMD_PERM_OTHER_WRITE, GNOME_CMD_PERM_OTHER_EXEC}
};
@@ -202,7 +202,7 @@ GtkType gnome_cmd_chmod_component_get_type ()
return type;
}
-
+//TODO: Change this function to return guint32
GnomeVFSFilePermissions gnome_cmd_chmod_component_get_perms (GnomeCmdChmodComponent *comp)
{
guint perms = 0;
diff --git a/src/gnome-cmd-con.cc b/src/gnome-cmd-con.cc
index 1d9f88df..87e639c8 100644
--- a/src/gnome-cmd-con.cc
+++ b/src/gnome-cmd-con.cc
@@ -465,9 +465,9 @@ GnomeVFSResult gnome_cmd_con_mkdir (GnomeCmdCon *con, const gchar *path_str)
result = gnome_vfs_make_directory_for_uri (
uri,
- GNOME_VFS_PERM_USER_READ|GNOME_VFS_PERM_USER_WRITE|GNOME_VFS_PERM_USER_EXEC|
- GNOME_VFS_PERM_GROUP_READ|GNOME_VFS_PERM_GROUP_EXEC|
- GNOME_VFS_PERM_OTHER_READ|GNOME_VFS_PERM_OTHER_EXEC);
+ GNOME_CMD_PERM_USER_READ|GNOME_CMD_PERM_USER_WRITE|GNOME_CMD_PERM_USER_EXEC|
+ GNOME_CMD_PERM_GROUP_READ|GNOME_CMD_PERM_GROUP_EXEC|
+ GNOME_CMD_PERM_OTHER_READ|GNOME_CMD_PERM_OTHER_EXEC);
gnome_vfs_uri_unref (uri);
delete path;
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 8d861e14..d4f1d417 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1265,7 +1265,7 @@ static void mime_exec_single (GnomeCmdFile *f)
if (ret != 1) return; else
{
- GnomeVFSResult result = f->chmod((GnomeVFSFilePermissions)
(f->info->permissions|GNOME_VFS_PERM_USER_EXEC));
+ GnomeVFSResult result = f->chmod((GnomeVFSFilePermissions)
(f->info->permissions|GNOME_CMD_PERM_USER_EXEC));
if (result != GNOME_VFS_OK)
return;
}
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index be4811ff..d5a87e20 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -708,9 +708,7 @@ const gchar *GnomeCmdFile::get_perm()
{
static gchar perm_str[MAX_PERM_LENGTH];
- g_return_val_if_fail (info != nullptr, nullptr);
-
- perm2string (info->permissions, perm_str, MAX_PERM_LENGTH);
+ perm2string (GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_UNIX_MODE) & 0xFFF, perm_str, MAX_PERM_LENGTH);
return perm_str;
}
@@ -908,13 +906,13 @@ gboolean GnomeCmdFile::is_executable()
if (!is_local())
return FALSE;
- if (gcmd_owner.uid() == info->uid && info->permissions & GNOME_VFS_PERM_USER_EXEC)
+ if (gcmd_owner.uid() == info->uid && info->permissions & GNOME_CMD_PERM_USER_EXEC)
return TRUE;
- if (gcmd_owner.gid() == info->gid && info->permissions & GNOME_VFS_PERM_GROUP_EXEC)
+ if (gcmd_owner.gid() == info->gid && info->permissions & GNOME_CMD_PERM_GROUP_EXEC)
return TRUE;
- if (info->permissions & GNOME_VFS_PERM_OTHER_EXEC)
+ if (info->permissions & GNOME_CMD_PERM_OTHER_EXEC)
return TRUE;
return FALSE;
diff --git a/src/tags/gnome-cmd-tags-file.cc b/src/tags/gnome-cmd-tags-file.cc
index cb91d703..a9a79d15 100644
--- a/src/tags/gnome-cmd-tags-file.cc
+++ b/src/tags/gnome-cmd-tags-file.cc
@@ -65,7 +65,7 @@ void gcmd_tags_file_load_metadata(GnomeCmdFile *f)
strftime(buff,sizeof(buff),"%Y-%m-%d %T",localtime(&f->info->mtime));
f->metadata->add(TAG_FILE_MODIFIED, buff);
- f->metadata->add(TAG_FILE_PERMISSIONS, perm2textstring(f->info->permissions,buff,sizeof(buff)));
+ f->metadata->add(TAG_FILE_PERMISSIONS,
perm2textstring(f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_UNIX_MODE),buff,sizeof(buff)));
f->metadata->add(TAG_FILE_FORMAT, f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) ==
G_FILE_TYPE_DIRECTORY ? "Folder" : f->info->mime_type);
}
diff --git a/src/utils.cc b/src/utils.cc
index c13f7a6a..6323d66a 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -266,54 +266,54 @@ const gchar *type2string (guint32 type, gchar *buf, guint max)
}
-const gchar *perm2string (GnomeVFSFilePermissions p, gchar *buf, guint max)
+const gchar *perm2string (guint32 permissions, gchar *buf, guint max)
{
switch (gnome_cmd_data.options.perm_disp_mode)
{
case GNOME_CMD_PERM_DISP_MODE_TEXT:
- return perm2textstring (p, buf, max);
+ return perm2textstring (permissions, buf, max);
case GNOME_CMD_PERM_DISP_MODE_NUMBER:
- return perm2numstring (p, buf, max);
+ return perm2numstring (permissions, buf, max);
default:
- return perm2textstring (p, buf, max);
+ return perm2textstring (permissions, buf, max);
}
}
-const gchar *perm2textstring (GnomeVFSFilePermissions p, gchar *buf, guint max)
+const gchar *perm2textstring (guint32 permissions, gchar *buf, guint max)
{
g_snprintf (buf, max, "%s%s%s%s%s%s%s%s%s",
- (p & GNOME_VFS_PERM_USER_READ) ? "r" : "-",
- (p & GNOME_VFS_PERM_USER_WRITE) ? "w" : "-",
- (p & GNOME_VFS_PERM_USER_EXEC) ? "x" : "-",
- (p & GNOME_VFS_PERM_GROUP_READ) ? "r" : "-",
- (p & GNOME_VFS_PERM_GROUP_WRITE) ? "w" : "-",
- (p & GNOME_VFS_PERM_GROUP_EXEC) ? "x" : "-",
- (p & GNOME_VFS_PERM_OTHER_READ) ? "r" : "-",
- (p & GNOME_VFS_PERM_OTHER_WRITE) ? "w" : "-",
- (p & GNOME_VFS_PERM_OTHER_EXEC) ? "x" : "-");
+ (permissions & GNOME_CMD_PERM_USER_READ) ? "r" : "-",
+ (permissions & GNOME_CMD_PERM_USER_WRITE) ? "w" : "-",
+ (permissions & GNOME_CMD_PERM_USER_EXEC) ? "x" : "-",
+ (permissions & GNOME_CMD_PERM_GROUP_READ) ? "r" : "-",
+ (permissions & GNOME_CMD_PERM_GROUP_WRITE) ? "w" : "-",
+ (permissions & GNOME_CMD_PERM_GROUP_EXEC) ? "x" : "-",
+ (permissions & GNOME_CMD_PERM_OTHER_READ) ? "r" : "-",
+ (permissions & GNOME_CMD_PERM_OTHER_WRITE) ? "w" : "-",
+ (permissions & GNOME_CMD_PERM_OTHER_EXEC) ? "x" : "-");
return buf;
}
-const gchar *perm2numstring (GnomeVFSFilePermissions p, gchar *buf, guint max)
+const gchar *perm2numstring (guint32 permissions, gchar *buf, guint max)
{
gint i = 0;
- if (p & GNOME_VFS_PERM_USER_READ) i += 400;
- if (p & GNOME_VFS_PERM_USER_WRITE) i += 200;
- if (p & GNOME_VFS_PERM_USER_EXEC) i += 100;
- if (p & GNOME_VFS_PERM_GROUP_READ) i += 40;
- if (p & GNOME_VFS_PERM_GROUP_WRITE) i += 20;
- if (p & GNOME_VFS_PERM_GROUP_EXEC) i += 10;
- if (p & GNOME_VFS_PERM_OTHER_READ) i += 4;
- if (p & GNOME_VFS_PERM_OTHER_WRITE) i += 2;
- if (p & GNOME_VFS_PERM_OTHER_EXEC) i += 1;
-
- g_snprintf (buf, max, "%d", i);
+ if (permissions & GNOME_CMD_PERM_USER_READ) i += 400;
+ if (permissions & GNOME_CMD_PERM_USER_WRITE) i += 200;
+ if (permissions & GNOME_CMD_PERM_USER_EXEC) i += 100;
+ if (permissions & GNOME_CMD_PERM_GROUP_READ) i += 40;
+ if (permissions & GNOME_CMD_PERM_GROUP_WRITE) i += 20;
+ if (permissions & GNOME_CMD_PERM_GROUP_EXEC) i += 10;
+ if (permissions & GNOME_CMD_PERM_OTHER_READ) i += 4;
+ if (permissions & GNOME_CMD_PERM_OTHER_WRITE) i += 2;
+ if (permissions & GNOME_CMD_PERM_OTHER_EXEC) i += 1;
+
+ g_snprintf (buf, max, "%i", i);
return buf;
}
diff --git a/src/utils.h b/src/utils.h
index d6206404..4666d265 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -37,6 +37,19 @@
using namespace std;
+#define GNOME_CMD_PERM_USER_READ 256 //r--------
+#define GNOME_CMD_PERM_USER_WRITE 128 //-w-------
+#define GNOME_CMD_PERM_USER_EXEC 64 //--x------
+#define GNOME_CMD_PERM_GROUP_READ 32 //---r-----
+#define GNOME_CMD_PERM_GROUP_WRITE 16 //----w----
+#define GNOME_CMD_PERM_GROUP_EXEC 8 //-----x---
+#define GNOME_CMD_PERM_OTHER_READ 4 //------r--
+#define GNOME_CMD_PERM_OTHER_WRITE 2 //-------w-
+#define GNOME_CMD_PERM_OTHER_EXEC 1 //--------x
+#define GNOME_CMD_PERM_USER_ALL 448 //rwx------
+#define GNOME_CMD_PERM_GROUP_ALL 56 //---rwx---
+#define GNOME_CMD_PERM_OTHER_ALL 7 //------rwx
+
#define TRACE(s) std::cout << __FILE__ "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << "\t" #s ": `" <<
(s) << "'" << std::endl
extern gchar *debug_flags;
@@ -121,9 +134,9 @@ inline char *int2string (gint i)
}
const gchar *type2string (guint32 type, gchar *buf, guint max);
-const gchar *perm2string (GnomeVFSFilePermissions p, gchar *buf, guint max);
-const gchar *perm2textstring (GnomeVFSFilePermissions p, gchar *buf, guint max);
-const gchar *perm2numstring (GnomeVFSFilePermissions p, gchar *buf, guint max);
+const gchar *perm2string (guint32 permissions, gchar *buf, guint max);
+const gchar *perm2textstring (guint32 permissions, gchar *buf, guint max);
+const gchar *perm2numstring (guint32 permissions, gchar *buf, guint max);
const gchar *size2string (GnomeVFSFileSize size, GnomeCmdSizeDispMode size_disp_mode);
const gchar *time2string (time_t t, const gchar *date_format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]