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
This commit is contained in:
Dimitar Zhekov 2015-10-05 22:52:54 +03:00 committed by Matthew Brush
parent c6952c7599
commit d6e94cf9d4
5 changed files with 13 additions and 13 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);
}

View File

@ -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)

View File

@ -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)
{