Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: Diff | Size: 8.00 KB | Hits: 46 | Expires: Never
Copy text to clipboard
  1. diff --git a/gio/giomodule.c b/gio/giomodule.c
  2. index 1f2e0bc..3f1abcd 100644
  3. --- a/gio/giomodule.c
  4. +++ b/gio/giomodule.c
  5. @@ -270,11 +270,7 @@ g_io_modules_scan_all_in_directory (const char *dirname)
  6.    const gchar *name;
  7.    char *filename;
  8.    GDir *dir;
  9. -#ifdef G_OS_WIN32
  10. -  struct _g_stat_struct statbuf;
  11. -#else
  12. -  struct stat statbuf;
  13. -#endif
  14. +  struct g_stat_struct statbuf;
  15.    char *data;
  16.    time_t cache_mtime;
  17.    GHashTable *cache;
  18. diff --git a/gio/glocalfile.c b/gio/glocalfile.c
  19. index ec290e7..144d5cb 100644
  20. --- a/gio/glocalfile.c
  21. +++ b/gio/glocalfile.c
  22. @@ -107,11 +107,6 @@
  23.  
  24.  #include "gioalias.h"
  25.  
  26. -/* See gstdio.h */
  27. -#ifndef G_OS_WIN32
  28. -#define _g_stat_struct stat
  29. -#endif
  30. -
  31.  static void g_local_file_file_iface_init (GFileIface *iface);
  32.  
  33.  static GFileAttributeInfoList *local_writable_attributes = NULL;
  34. @@ -741,7 +736,7 @@ get_mount_info (GFileInfo             *fs_info,
  35.                 const char            *path,
  36.                 GFileAttributeMatcher *matcher)
  37.  {
  38. -  struct _g_stat_struct buf;
  39. +  struct g_stat_struct buf;
  40.    gboolean got_info;
  41.    gpointer info_as_ptr;
  42.    guint mount_info;
  43. @@ -1052,7 +1047,7 @@ g_local_file_find_enclosing_mount (GFile         *file,
  44.                                     GError       **error)
  45.  {
  46.    GLocalFile *local = G_LOCAL_FILE (file);
  47. -  struct _g_stat_struct buf;
  48. +  struct g_stat_struct buf;
  49.    char *mountpoint;
  50.    GMount *mount;
  51.  
  52. @@ -1098,7 +1093,7 @@ g_local_file_set_display_name (GFile         *file,
  53.  {
  54.    GLocalFile *local, *new_local;
  55.    GFile *new_file, *parent;
  56. -  struct _g_stat_struct statbuf;
  57. +  struct g_stat_struct statbuf;
  58.    GVfsClass *class;
  59.    GVfs *vfs;
  60.    int errsv;
  61. @@ -1516,7 +1511,7 @@ get_parent (const char *path,
  62.              dev_t      *parent_dev)
  63.  {
  64.    char *parent, *tmp;
  65. -  struct _g_stat_struct parent_stat;
  66. +  struct g_stat_struct parent_stat;
  67.    int num_recursions;
  68.    char *path_copy;
  69.  
  70. @@ -1725,12 +1720,12 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
  71.    char *topdir, *globaldir, *trashdir, *tmpname;
  72.    uid_t uid;
  73.    char uid_str[32];
  74. -  struct _g_stat_struct global_stat, trash_stat;
  75. +  struct g_stat_struct global_stat, trash_stat;
  76.    gboolean res;
  77.  
  78.    if (g_once_init_enter (&home_dev_set))
  79.      {
  80. -      struct _g_stat_struct home_stat;
  81. +      struct g_stat_struct home_stat;
  82.  
  83.        g_stat (g_get_home_dir (), &home_stat);
  84.        home_dev = home_stat.st_dev;
  85. @@ -1792,7 +1787,7 @@ g_local_file_trash (GFile         *file,
  86.                     GError       **error)
  87.  {
  88.    GLocalFile *local = G_LOCAL_FILE (file);
  89. -  struct _g_stat_struct file_stat, home_stat;
  90. +  struct g_stat_struct file_stat, home_stat;
  91.    const char *homedir;
  92.    char *trashdir, *topdir, *infodir, *filesdir;
  93.    char *basename, *trashname, *trashfile, *infoname, *infofile;
  94. @@ -1802,7 +1797,7 @@ g_local_file_trash (GFile         *file,
  95.    gboolean is_homedir_trash;
  96.    char delete_time[32];
  97.    int fd;
  98. -  struct _g_stat_struct trash_stat, global_stat;
  99. +  struct g_stat_struct trash_stat, global_stat;
  100.    char *dirname, *globaldir;
  101.    GVfsClass *class;
  102.    GVfs *vfs;
  103. @@ -2207,7 +2202,7 @@ g_local_file_move (GFile                  *source,
  104.                    GError                **error)
  105.  {
  106.    GLocalFile *local_source, *local_destination;
  107. -  struct _g_stat_struct statbuf;
  108. +  struct g_stat_struct statbuf;
  109.    gboolean destination_exist, source_is_dir;
  110.    char *backup_name;
  111.    int res;
  112. diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
  113. index a913e82..2bd59f4 100644
  114. --- a/gio/glocalfileinfo.c
  115. +++ b/gio/glocalfileinfo.c
  116. @@ -96,11 +96,6 @@
  117.  
  118.  #include "gioalias.h"
  119.  
  120. -/* See gstdio.h */
  121. -#ifndef G_OS_WIN32
  122. -#define _g_stat_struct stat
  123. -#endif
  124. -
  125.  struct ThumbMD5Context {
  126.         guint32 buf[4];
  127.         guint32 bits[2];
  128. @@ -793,7 +788,7 @@ _g_local_file_info_get_parent_info (const char            *dir,
  129.                                     GFileAttributeMatcher *attribute_matcher,
  130.                                     GLocalParentFileInfo  *parent_info)
  131.  {
  132. -  struct _g_stat_struct statbuf;
  133. +  struct g_stat_struct statbuf;
  134.    int res;
  135.  
  136.    parent_info->extra_data = NULL;
  137. diff --git a/glib/gstdio.c b/glib/gstdio.c
  138. index 542a95e..f6c478f 100644
  139. --- a/glib/gstdio.c
  140. +++ b/glib/gstdio.c
  141. @@ -438,6 +438,19 @@ g_chdir (const gchar *path)
  142.   * not look at the ACL at all. Thus on Windows the protection bits in
  143.   * the st_mode field are a fabrication of little use.
  144.   *
  145. + * On Windows the Microsoft C libraries have several variants of the
  146. + * <structname>stat</structname> struct and stat() function with names
  147. + * like "_stat", "_stat32", "_stat32i64" and "_stat64i32". The one
  148. + * used here is for 32-bit code the one with 32-bit size and time
  149. + * fields, specifically called "_stat32".
  150. + *
  151. + * In Microsoft's compiler, by default "struct stat" means one with
  152. + * 64-bit time fields while in MinGW "struct stat" is the legacy one
  153. + * with 32-bit fields. To hopefully clear up this messs, the gstdio.h
  154. + * header defines a macro g_stat_struct that expands to the
  155. + * appropriate struct tag depending on the compiler being used. On
  156. + * POSIX it expands to just "stat".
  157. + *
  158.   * See your C library manual for more details about stat().
  159.   *
  160.   * Returns: 0 if the information was successfully retrieved, -1 if an error
  161. @@ -446,13 +459,8 @@ g_chdir (const gchar *path)
  162.   * Since: 2.6
  163.   */
  164.  int
  165. -g_stat (const gchar           *filename,
  166. -#ifdef G_OS_WIN32
  167. -       struct _g_stat_struct *buf
  168. -#else
  169. -       struct stat           *buf
  170. -#endif
  171. -                                 )
  172. +g_stat (const gchar          *filename,
  173. +       struct g_stat_struct *buf)
  174.  {
  175.  #ifdef G_OS_WIN32
  176.    wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
  177. @@ -505,13 +513,8 @@ g_stat (const gchar           *filename,
  178.   * Since: 2.6
  179.   */
  180.  int
  181. -g_lstat (const gchar           *filename,
  182. -#ifdef G_OS_WIN32
  183. -        struct _g_stat_struct *buf
  184. -#else
  185. -        struct stat           *buf
  186. -#endif
  187. -                                  )
  188. +g_lstat (const gchar          *filename,
  189. +        struct g_stat_struct *buf)
  190.  {
  191.  #ifdef HAVE_LSTAT
  192.    /* This can't be Win32, so don't do the widechar dance. */
  193. diff --git a/glib/gstdio.h b/glib/gstdio.h
  194. index b61bc6b..d454f8e 100644
  195. --- a/glib/gstdio.h
  196. +++ b/glib/gstdio.h
  197. @@ -91,10 +91,6 @@ int g_chdir     (const gchar *path);
  198.  
  199.  #ifdef G_OS_WIN32
  200.  
  201. -/* The _g_stat_struct struct tag is an internal implementation detail
  202. - * and not part of the public GLib API.
  203. - */
  204. -
  205.  #if defined (_MSC_VER) && !defined(_WIN64)
  206.  
  207.  /* Make it clear that we mean the struct with 32-bit st_size and
  208. @@ -102,35 +98,35 @@ int g_chdir     (const gchar *path);
  209.   * has been compiled. If you get a compiler warning when calling
  210.   * g_stat(), do take it seriously and make sure that the type of
  211.   * struct stat the code in GLib fills in matches the struct the type
  212. - * of struct stat you pass to g_stat(). To avoid hassle, just use the
  213. - * GIO API instead which doesn't use struct stat to get file
  214. - * attributes, .
  215. + * of struct stat you pass to g_stat(). To avoid hassle, to get file
  216. + * attributes just use the GIO API instead which doesn't use struct
  217. + * stat.
  218. + *
  219. + * Sure, it would be nicer to use a struct with 64-bit st_size and
  220. + * 64-bit st_*time fields, but changing that now would break ABI. And
  221. + * in MinGW, a plain "struct stat" is the one with 32-bit st_size and
  222. + * st_*time fields.
  223.   */
  224. -#define _g_stat_struct _stat32
  225. +
  226. +#define g_stat_struct _stat32
  227.  
  228.  #else
  229.  
  230. -#define _g_stat_struct _stat
  231. +#define g_stat_struct _stat
  232.  
  233.  #endif
  234.  
  235. -int g_stat      (const gchar           *filename,
  236. -                 struct _g_stat_struct *buf);
  237. -
  238. -int g_lstat     (const gchar           *filename,
  239. -                 struct _g_stat_struct *buf);
  240. -
  241.  #else
  242.  
  243. -/* No _g_stat_struct used on Unix */
  244. +#define g_stat_struct stat
  245.  
  246. -int g_stat      (const gchar *filename,
  247. -                 struct stat *buf);
  248. +#endif
  249.  
  250. -int g_lstat     (const gchar *filename,
  251. -                 struct stat *buf);
  252. +int g_stat      (const gchar           *filename,
  253. +                 struct g_stat_struct *buf);
  254.  
  255. -#endif
  256. +int g_lstat     (const gchar           *filename,
  257. +                 struct g_stat_struct *buf);
  258.  
  259.  int g_unlink    (const gchar *filename);