2010-04-11 18:50:19 -07:00
|
|
|
#ifndef MOO_STAT_H
|
|
|
|
#define MOO_STAT_H
|
|
|
|
|
2015-12-25 18:07:33 -08:00
|
|
|
#include <mooglib/moo-glib.h>
|
2010-04-11 18:50:19 -07:00
|
|
|
|
2011-01-08 18:03:58 -08:00
|
|
|
#undef MOO_G_STAT_BROKEN
|
|
|
|
|
|
|
|
#if defined(G_OS_WIN32) && GLIB_CHECK_VERSION(2,22,0) && !GLIB_CHECK_VERSION(2,26,0)
|
|
|
|
#define MOO_G_STAT_BROKEN 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOO_G_STAT_BROKEN
|
2010-04-11 18:50:19 -07:00
|
|
|
|
|
|
|
inline static void _moo_check_stat_struct(void)
|
|
|
|
{
|
|
|
|
struct _g_stat_struct statbuf;
|
|
|
|
// check that _g_stat_struct is the same as plain struct stat
|
|
|
|
_off_t *pofft = &statbuf.st_size;
|
|
|
|
time_t *ptimet = &statbuf.st_atime;
|
|
|
|
(void) pofft;
|
|
|
|
(void) ptimet;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
inline static int moo_stat (const char *filename, struct stat *buf)
|
|
|
|
{
|
2011-01-08 18:03:58 -08:00
|
|
|
#ifdef MOO_G_STAT_BROKEN
|
2010-04-11 18:50:19 -07:00
|
|
|
/* _moo_check_stat_struct above checks that struct stat is okay,
|
|
|
|
cast to void* is to avoid using glib's internal _g_stat_struct */
|
2010-08-12 18:17:00 -07:00
|
|
|
return g_stat (filename, (struct _g_stat_struct*) buf);
|
2010-04-11 18:50:19 -07:00
|
|
|
#else
|
|
|
|
return g_stat (filename, buf);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static int moo_lstat (const char *filename, struct stat *buf)
|
|
|
|
{
|
2011-01-08 18:03:58 -08:00
|
|
|
#ifdef MOO_G_STAT_BROKEN
|
2010-04-11 18:50:19 -07:00
|
|
|
/* _moo_check_stat_struct above checks that struct stat is okay,
|
|
|
|
cast to void* is to avoid using glib's internal _g_stat_struct */
|
2010-08-12 18:17:00 -07:00
|
|
|
return g_lstat (filename, (struct _g_stat_struct*) buf);
|
2010-04-11 18:50:19 -07:00
|
|
|
#else
|
|
|
|
return g_lstat (filename, buf);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* MOO_STAT_H */
|