[geany/geany] d6e94c: Use GStatBuf instead of plain `struct stat`

Dimitar Zhekov git-noreply at xxxxx
Thu Oct 8 00:16:09 UTC 2015


Branch:      refs/heads/master
Author:      Dimitar Zhekov <dimitar.zhekov at gmail.com>
Committer:   Matthew Brush <matt at geany.org>
Date:        Thu, 08 Oct 2015 00:16:09 UTC
Commit:      d6e94cf9d4b41b55f06bafe185b1b0a7fc61bd30
             https://github.com/geany/geany/commit/d6e94cf9d4b41b55f06bafe185b1b0a7fc61bd30

Log Message:
-----------
Use GStatBuf instead of plain `struct stat`

Especially under Windows, there are 32-bit and 64-bit stat, and
g_[l]stat may use the non-default one.

Closes #677


Modified Paths:
--------------
    src/dialogs.c
    src/socket.c
    tagmanager/ctags/ctags.c
    tagmanager/src/tm_source_file.c
    tagmanager/src/tm_workspace.c

Modified: src/dialogs.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1152,7 +1152,7 @@ void dialogs_show_file_properties(GeanyDocument *doc)
 	gchar *file_size, *title, *base_name, *time_changed, *time_modified, *time_accessed, *enctext;
 	gchar *short_name;
 #ifdef HAVE_SYS_TYPES_H
-	struct stat st;
+	GStatBuf st;
 	off_t filesize;
 	mode_t mode;
 	gchar *locale_filename;


Modified: src/socket.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -225,7 +225,7 @@ static void socket_get_document_list(gint sock)
 #ifndef G_OS_WIN32
 static void check_socket_permissions(void)
 {
-	struct stat socket_stat;
+	GStatBuf socket_stat;
 
 	if (g_lstat(socket_info.file_name, &socket_stat) == 0)
 	{	/* If the user id of the process is not the same as the owner of the socket


Modified: tagmanager/ctags/ctags.c
16 lines changed, 8 insertions(+), 8 deletions(-)
===================================================================
@@ -421,7 +421,7 @@ extern char* newUpperString (const char* str)
 
 extern long unsigned int getFileSize (const char *const name)
 {
-    struct stat fileStatus;
+    GStatBuf fileStatus;
     unsigned long size = 0;
 
     if (g_stat (name, &fileStatus) == 0)
@@ -436,7 +436,7 @@ static boolean isSymbolicLink (const char *const name)
 #if defined (MSDOS) || defined (WIN32) || defined (VMS) || defined (__EMX__) || defined (AMIGA)
     return FALSE;
 #else
-    struct stat fileStatus;
+    GStatBuf fileStatus;
     boolean result = FALSE;
 
     if (g_lstat (name, &fileStatus) == 0)
@@ -448,7 +448,7 @@ static boolean isSymbolicLink (const char *const name)
 
 static boolean isNormalFile (const char *const name)
 {
-    struct stat fileStatus;
+    GStatBuf fileStatus;
     boolean result = FALSE;
 
     if (g_stat (name, &fileStatus) == 0)
@@ -460,7 +460,7 @@ static boolean isNormalFile (const char *const name)
 
 extern boolean isExecutable (const char *const name)
 {
-    struct stat fileStatus;
+    GStatBuf fileStatus;
     boolean result = FALSE;
 
     if (g_stat (name, &fileStatus) == 0)
@@ -473,7 +473,7 @@ extern boolean isSameFile (const char *const name1, const char *const name2)
 {
     boolean result = FALSE;
 #ifdef HAVE_STAT_ST_INO
-    struct stat stat1, stat2;
+    GStatBuf stat1, stat2;
 
     if (g_stat (name1, &stat1) == 0  &&  g_stat (name2, &stat2) == 0)
 	result = (boolean) (stat1.st_ino == stat2.st_ino);
@@ -488,7 +488,7 @@ static boolean isSetUID (const char *const name)
 #if defined (VMS) || defined (MSDOS) || defined (WIN32) || defined (__EMX__) || defined (AMIGA)
     return FALSE;
 #else
-    struct stat fileStatus;
+    GStatBuf fileStatus;
     boolean result = FALSE;
 
     if (g_stat (name, &fileStatus) == 0)
@@ -520,7 +520,7 @@ static boolean isDirectory (const char *const name)
 	eFree (fib);
     }
 #else
-    struct stat fileStatus;
+    GStatBuf fileStatus;
 
     if (g_stat (name, &fileStatus) == 0)
 	result = (boolean) S_ISDIR (fileStatus.st_mode);
@@ -531,7 +531,7 @@ static boolean isDirectory (const char *const name)
 
 extern boolean doesFileExist (const char *const fileName)
 {
-    struct stat fileStatus;
+    GStatBuf fileStatus;
 
     return (boolean) (g_stat (fileName, &fileStatus) == 0);
 }


Modified: tagmanager/src/tm_source_file.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -142,7 +142,7 @@ static void tm_source_file_set_tag_arglist(const char *tag_name, const char *arg
 static gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name, 
 	const char* name)
 {
-	struct stat s;
+	GStatBuf s;
 	int status;
 
 #ifdef TM_DEBUG
@@ -269,7 +269,7 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gsize
 	
 	if (!use_buffer)
 	{
-		struct stat s;
+		GStatBuf s;
 		
 		/* load file to memory and parse it from memory unless the file is too big */
 		if (g_stat(file_name, &s) != 0 || s.st_size > 10*1024*1024)


Modified: tagmanager/src/tm_workspace.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -391,7 +391,7 @@ gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode)
 
 static guint tm_file_inode_hash(gconstpointer key)
 {
-	struct stat file_stat;
+	GStatBuf file_stat;
 	const char *filename = (const char*)key;
 	if (g_stat(filename, &file_stat) == 0)
 	{



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list