const gchar *name;
char *filename;
GDir *dir;
-#ifdef G_OS_WIN32
- struct _g_stat_struct statbuf;
-#else
- struct stat statbuf;
-#endif
+ GStatBuf statbuf;
char *data;
time_t cache_mtime;
GHashTable *cache;
#include "gioalias.h"
-/* See gstdio.h */
-#ifndef G_OS_WIN32
-#define _g_stat_struct stat
-#endif
-
static void g_local_file_file_iface_init (GFileIface *iface);
static GFileAttributeInfoList *local_writable_attributes = NULL;
const char *path,
GFileAttributeMatcher *matcher)
{
- struct _g_stat_struct buf;
+ GStatBuf buf;
gboolean got_info;
gpointer info_as_ptr;
guint mount_info;
GError **error)
{
GLocalFile *local = G_LOCAL_FILE (file);
- struct _g_stat_struct buf;
+ GStatBuf buf;
char *mountpoint;
GMount *mount;
{
GLocalFile *local, *new_local;
GFile *new_file, *parent;
- struct _g_stat_struct statbuf;
+ GStatBuf statbuf;
GVfsClass *class;
GVfs *vfs;
int errsv;
dev_t *parent_dev)
{
char *parent, *tmp;
- struct _g_stat_struct parent_stat;
+ GStatBuf parent_stat;
int num_recursions;
char *path_copy;
char *topdir, *globaldir, *trashdir, *tmpname;
uid_t uid;
char uid_str[32];
- struct _g_stat_struct global_stat, trash_stat;
+ GStatBuf global_stat, trash_stat;
gboolean res;
if (g_once_init_enter (&home_dev_set))
{
- struct _g_stat_struct home_stat;
+ GStatBuf home_stat;
g_stat (g_get_home_dir (), &home_stat);
home_dev = home_stat.st_dev;
GError **error)
{
GLocalFile *local = G_LOCAL_FILE (file);
- struct _g_stat_struct file_stat, home_stat;
+ GStatBuf file_stat, home_stat;
const char *homedir;
char *trashdir, *topdir, *infodir, *filesdir;
char *basename, *trashname, *trashfile, *infoname, *infofile;
gboolean is_homedir_trash;
char delete_time[32];
int fd;
- struct _g_stat_struct trash_stat, global_stat;
+ GStatBuf trash_stat, global_stat;
char *dirname, *globaldir;
GVfsClass *class;
GVfs *vfs;
GError **error)
{
GLocalFile *local_source, *local_destination;
- struct _g_stat_struct statbuf;
+ GStatBuf statbuf;
gboolean destination_exist, source_is_dir;
char *backup_name;
int res;
#include "gioalias.h"
-/* See gstdio.h */
-#ifndef G_OS_WIN32
-#define _g_stat_struct stat
-#endif
-
struct ThumbMD5Context {
guint32 buf[4];
guint32 bits[2];
GFileAttributeMatcher *attribute_matcher,
GLocalParentFileInfo *parent_info)
{
- struct _g_stat_struct statbuf;
+ GStatBuf statbuf;
int res;
parent_info->extra_data = NULL;
* not look at the ACL at all. Thus on Windows the protection bits in
* the st_mode field are a fabrication of little use.
*
+ * On Windows the Microsoft C libraries have several variants of the
+ * <structname>stat</structname> struct and stat() function with names
+ * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
+ * used here is for 32-bit code the one with 32-bit size and time
+ * fields, specifically called "_stat32".
+ *
+ * In Microsoft's compiler, by default "struct stat" means one with
+ * 64-bit time fields while in MinGW "struct stat" is the legacy one
+ * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
+ * header defines a type GStatBuf which is the appropriate struct type
+ * depending on the platform and/or compiler being used. On POSIX it
+ * is just "struct stat", but note that even on POSIX platforms,
+ * "stat" might be a macro.
+ *
* See your C library manual for more details about stat().
*
* Returns: 0 if the information was successfully retrieved, -1 if an error
* Since: 2.6
*/
int
-g_stat (const gchar *filename,
-#ifdef G_OS_WIN32
- struct _g_stat_struct *buf
-#else
- struct stat *buf
-#endif
- )
+g_stat (const gchar *filename,
+ GStatBuf *buf)
{
#ifdef G_OS_WIN32
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
* Since: 2.6
*/
int
-g_lstat (const gchar *filename,
-#ifdef G_OS_WIN32
- struct _g_stat_struct *buf
-#else
- struct stat *buf
-#endif
- )
+g_lstat (const gchar *filename,
+ GStatBuf *buf)
{
#ifdef HAVE_LSTAT
/* This can't be Win32, so don't do the widechar dance. */
int g_chdir (const gchar *path);
-#ifdef G_OS_WIN32
-
-/* The _g_stat_struct struct tag is an internal implementation detail
- * and not part of the public GLib API.
- */
-
#if defined (_MSC_VER) && !defined(_WIN64)
/* Make it clear that we mean the struct with 32-bit st_size and
* has been compiled. If you get a compiler warning when calling
* g_stat(), do take it seriously and make sure that the type of
* struct stat the code in GLib fills in matches the struct the type
- * of struct stat you pass to g_stat(). To avoid hassle, just use the
- * GIO API instead which doesn't use struct stat to get file
- * attributes, .
+ * of struct stat you pass to g_stat(). To avoid hassle, to get file
+ * attributes just use the GIO API instead which doesn't use struct
+ * stat.
+ *
+ * Sure, it would be nicer to use a struct with 64-bit st_size and
+ * 64-bit st_*time fields, but changing that now would break ABI. And
+ * in MinGW, a plain "struct stat" is the one with 32-bit st_size and
+ * st_*time fields.
*/
-#define _g_stat_struct _stat32
+
+typedef struct _stat32 GStatBuf;
#else
-#define _g_stat_struct _stat
+typedef struct stat GStatBuf;
#endif
-int g_stat (const gchar *filename,
- struct _g_stat_struct *buf);
-
-int g_lstat (const gchar *filename,
- struct _g_stat_struct *buf);
-
-#else
-
-/* No _g_stat_struct used on Unix */
-
int g_stat (const gchar *filename,
- struct stat *buf);
+ GStatBuf *buf);
int g_lstat (const gchar *filename,
- struct stat *buf);
-
-#endif
+ GStatBuf *buf);
int g_unlink (const gchar *filename);