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:
parent
c6952c7599
commit
d6e94cf9d4
@ -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 *file_size, *title, *base_name, *time_changed, *time_modified, *time_accessed, *enctext;
|
||||||
gchar *short_name;
|
gchar *short_name;
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
struct stat st;
|
GStatBuf st;
|
||||||
off_t filesize;
|
off_t filesize;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
gchar *locale_filename;
|
gchar *locale_filename;
|
||||||
|
@ -225,7 +225,7 @@ static void socket_get_document_list(gint sock)
|
|||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
static void check_socket_permissions(void)
|
static void check_socket_permissions(void)
|
||||||
{
|
{
|
||||||
struct stat socket_stat;
|
GStatBuf socket_stat;
|
||||||
|
|
||||||
if (g_lstat(socket_info.file_name, &socket_stat) == 0)
|
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
|
{ /* If the user id of the process is not the same as the owner of the socket
|
||||||
|
@ -421,7 +421,7 @@ extern char* newUpperString (const char* str)
|
|||||||
|
|
||||||
extern long unsigned int getFileSize (const char *const name)
|
extern long unsigned int getFileSize (const char *const name)
|
||||||
{
|
{
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
unsigned long size = 0;
|
unsigned long size = 0;
|
||||||
|
|
||||||
if (g_stat (name, &fileStatus) == 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)
|
#if defined (MSDOS) || defined (WIN32) || defined (VMS) || defined (__EMX__) || defined (AMIGA)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
#else
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
boolean result = FALSE;
|
boolean result = FALSE;
|
||||||
|
|
||||||
if (g_lstat (name, &fileStatus) == 0)
|
if (g_lstat (name, &fileStatus) == 0)
|
||||||
@ -448,7 +448,7 @@ static boolean isSymbolicLink (const char *const name)
|
|||||||
|
|
||||||
static boolean isNormalFile (const char *const name)
|
static boolean isNormalFile (const char *const name)
|
||||||
{
|
{
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
boolean result = FALSE;
|
boolean result = FALSE;
|
||||||
|
|
||||||
if (g_stat (name, &fileStatus) == 0)
|
if (g_stat (name, &fileStatus) == 0)
|
||||||
@ -460,7 +460,7 @@ static boolean isNormalFile (const char *const name)
|
|||||||
|
|
||||||
extern boolean isExecutable (const char *const name)
|
extern boolean isExecutable (const char *const name)
|
||||||
{
|
{
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
boolean result = FALSE;
|
boolean result = FALSE;
|
||||||
|
|
||||||
if (g_stat (name, &fileStatus) == 0)
|
if (g_stat (name, &fileStatus) == 0)
|
||||||
@ -473,7 +473,7 @@ extern boolean isSameFile (const char *const name1, const char *const name2)
|
|||||||
{
|
{
|
||||||
boolean result = FALSE;
|
boolean result = FALSE;
|
||||||
#ifdef HAVE_STAT_ST_INO
|
#ifdef HAVE_STAT_ST_INO
|
||||||
struct stat stat1, stat2;
|
GStatBuf stat1, stat2;
|
||||||
|
|
||||||
if (g_stat (name1, &stat1) == 0 && g_stat (name2, &stat2) == 0)
|
if (g_stat (name1, &stat1) == 0 && g_stat (name2, &stat2) == 0)
|
||||||
result = (boolean) (stat1.st_ino == stat2.st_ino);
|
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)
|
#if defined (VMS) || defined (MSDOS) || defined (WIN32) || defined (__EMX__) || defined (AMIGA)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#else
|
#else
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
boolean result = FALSE;
|
boolean result = FALSE;
|
||||||
|
|
||||||
if (g_stat (name, &fileStatus) == 0)
|
if (g_stat (name, &fileStatus) == 0)
|
||||||
@ -520,7 +520,7 @@ static boolean isDirectory (const char *const name)
|
|||||||
eFree (fib);
|
eFree (fib);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
|
|
||||||
if (g_stat (name, &fileStatus) == 0)
|
if (g_stat (name, &fileStatus) == 0)
|
||||||
result = (boolean) S_ISDIR (fileStatus.st_mode);
|
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)
|
extern boolean doesFileExist (const char *const fileName)
|
||||||
{
|
{
|
||||||
struct stat fileStatus;
|
GStatBuf fileStatus;
|
||||||
|
|
||||||
return (boolean) (g_stat (fileName, &fileStatus) == 0);
|
return (boolean) (g_stat (fileName, &fileStatus) == 0);
|
||||||
}
|
}
|
||||||
|
@ -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,
|
static gboolean tm_source_file_init(TMSourceFile *source_file, const char *file_name,
|
||||||
const char* name)
|
const char* name)
|
||||||
{
|
{
|
||||||
struct stat s;
|
GStatBuf s;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#ifdef TM_DEBUG
|
#ifdef TM_DEBUG
|
||||||
@ -269,7 +269,7 @@ gboolean tm_source_file_parse(TMSourceFile *source_file, guchar* text_buf, gsize
|
|||||||
|
|
||||||
if (!use_buffer)
|
if (!use_buffer)
|
||||||
{
|
{
|
||||||
struct stat s;
|
GStatBuf s;
|
||||||
|
|
||||||
/* load file to memory and parse it from memory unless the file is too big */
|
/* 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)
|
if (g_stat(file_name, &s) != 0 || s.st_size > 10*1024*1024)
|
||||||
|
@ -391,7 +391,7 @@ gboolean tm_workspace_load_global_tags(const char *tags_file, gint mode)
|
|||||||
|
|
||||||
static guint tm_file_inode_hash(gconstpointer key)
|
static guint tm_file_inode_hash(gconstpointer key)
|
||||||
{
|
{
|
||||||
struct stat file_stat;
|
GStatBuf file_stat;
|
||||||
const char *filename = (const char*)key;
|
const char *filename = (const char*)key;
|
||||||
if (g_stat(filename, &file_stat) == 0)
|
if (g_stat(filename, &file_stat) == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user