#include "fcint.h"
#include "fcarch.h"
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#endif
#ifdef HAVE_SYS_STATVFS_H
#include <sys/statvfs.h>
#endif
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#include <errno.h>
#ifdef _WIN32
#ifdef __GNUC__
typedef long long INT64;
#define EPOCH_OFFSET …
#else
#define EPOCH_OFFSET …
typedef __int64 INT64;
#endif
int
FcStat (const FcChar8 *file, struct stat *statb)
{
WIN32_FILE_ATTRIBUTE_DATA wfad;
char full_path_name[MAX_PATH];
char *basename;
DWORD rc;
if (!GetFileAttributesEx ((LPCSTR) file, GetFileExInfoStandard, &wfad))
return -1;
statb->st_dev = 0;
rc = GetFullPathName ((LPCSTR) file, sizeof (full_path_name), full_path_name, &basename);
if (rc == 0 || rc > sizeof (full_path_name))
return -1;
rc = GetLongPathName (full_path_name, full_path_name, sizeof (full_path_name));
statb->st_ino = FcStringHash ((const FcChar8 *) full_path_name);
statb->st_mode = _S_IREAD | _S_IWRITE;
statb->st_mode |= (statb->st_mode >> 3) | (statb->st_mode >> 6);
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
statb->st_mode |= _S_IFDIR;
else
statb->st_mode |= _S_IFREG;
statb->st_nlink = 1;
statb->st_uid = statb->st_gid = 0;
statb->st_rdev = 0;
if (wfad.nFileSizeHigh > 0)
return -1;
statb->st_size = wfad.nFileSizeLow;
statb->st_atime = (*(INT64 *)&wfad.ftLastAccessTime)/10000000 - EPOCH_OFFSET;
statb->st_mtime = (*(INT64 *)&wfad.ftLastWriteTime)/10000000 - EPOCH_OFFSET;
statb->st_ctime = statb->st_mtime;
return 0;
}
#else
int
FcStat (const FcChar8 *file, struct stat *statb)
{ … }
struct Adler32 { … };
static void
Adler32Init (struct Adler32 *ctx)
{ … }
static void
Adler32Update (struct Adler32 *ctx, const char *data, int data_len)
{ … }
static int
Adler32Finish (struct Adler32 *ctx)
{ … }
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
static FcBool
FcDirChecksumScandirFilter(const struct dirent *entry)
{ … }
#endif
static int
FcDirChecksumScandirSorter(const struct dirent **lhs, const struct dirent **rhs)
{ … }
static void
free_dirent (struct dirent **p)
{ … }
int
FcScandir (const char *dirp,
struct dirent ***namelist,
int (*filter) (const struct dirent *),
int (*compar) (const struct dirent **, const struct dirent **));
int
FcScandir (const char *dirp,
struct dirent ***namelist,
int (*filter) (const struct dirent *),
int (*compar) (const struct dirent **, const struct dirent **))
{ … }
static int
FcDirChecksum (const FcChar8 *dir, time_t *checksum)
{ … }
#endif
int
FcStatChecksum (const FcChar8 *file, struct stat *statb)
{ … }
static int
FcFStatFs (int fd, FcStatFS *statb)
{ … }
FcBool
FcIsFsMmapSafe (int fd)
{ … }
FcBool
FcIsFsMtimeBroken (const FcChar8 *dir)
{ … }
#define __fcstat__
#include "fcaliastail.h"
#undef __fcstat__