int LastModifiedFile(const char *name, double *tp) { #ifdef __WINDOWS__ HANDLE hFile; wchar_t wfile[MAXPATHLEN]; #define nano * 0.000000001 #define ntick 100.0 #define SEC_TO_UNIX_EPOCH 11644473600.0 if ( !_xos_os_filenameW(name, wfile, MAXPATHLEN) ) return FALSE; if ( (hFile=CreateFileW(wfile, 0, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL)) != INVALID_HANDLE_VALUE ) { FILETIME wt; int rc; rc = GetFileTime(hFile, NULL, NULL, &wt); CloseHandle(hFile); if ( rc ) { double t; t = (double)wt.dwHighDateTime * (4294967296.0 * ntick nano); t += (double)wt.dwLowDateTime * (ntick nano); t -= SEC_TO_UNIX_EPOCH; *tp = t; return TRUE; } } set_posix_error(GetLastError()); return FALSE; #else char tmp[MAXPATHLEN]; statstruct buf; if ( statfunc(OsPath(name, tmp), &buf) < 0 ) return FALSE; #ifdef HAVE_STRUCT_STAT_ST_MTIM *tp = (double)buf.st_mtim.tv_sec + (double)buf.st_mtim.tv_nsec/1.0e9; #else *tp = (double)buf.st_mtime; #endif return TRUE; #endif }
static int64_t SizeFile(const char *path) { char tmp[MAXPATHLEN]; statstruct buf; if ( statfunc(OsPath(path, tmp), &buf) < 0 ) return -1; return buf.st_size; }
bool FolderArchive::FileExists (string filename) /////////////////////////////////////////////////////////////////////// { struct statstruct buf; if (!statfunc ( (m_szFolderName + filename).c_str(), &buf ) ) return true; return false; }
static void any_empty(int (*statfunc)(const char *, struct stat *), const char *call) { struct stat sb; char desc[128]; int rv; snprintf(desc, sizeof(desc), "%s on empty string", call); rv = statfunc("", &sb); report_test2(rv, errno, 0, EINVAL, desc); }
static void common_badbuf(int (*statfunc)(struct stat *), void *ptr, const char *call, const char *ptrdesc) { int rv; char mydesc[128]; snprintf(mydesc, sizeof(mydesc), "%s with %s buf", call, ptrdesc); rv = statfunc(ptr); report_test(rv, errno, EFAULT, mydesc); }
static int64_t SizeFile(const char *path) { char tmp[MAXPATHLEN]; statstruct buf; #ifdef __ANDROID__ if (Yap_isAsset(path)) { return Yap_AssetSize( path ); } #endif if ( statfunc(OsPath(path, tmp), &buf) < 0 ) return -1; return buf.st_size; }
int ExistsFile(const char *path) { #ifdef O_XOS return _xos_exists(path, _XOS_FILE); #else char tmp[MAXPATHLEN]; statstruct buf; if ( statfunc(OsPath(path, tmp), &buf) == -1 || !S_ISREG(buf.st_mode) ) { DEBUG(2, perror(tmp)); return FALSE; } return TRUE; #endif }
int ExistsDirectory(const char *path) { #ifdef O_XOS return _xos_exists(path, _XOS_DIR); #else char tmp[MAXPATHLEN]; char *ospath = OsPath(path, tmp); statstruct buf; if ( statfunc(ospath, &buf) < 0 ) return FALSE; if ( S_ISDIR(buf.st_mode) ) return TRUE; return FALSE; #endif /*O_XOS*/ }
int ExistsDirectory(const char *path) { #ifdef O_XOS return _xos_exists(path, _XOS_DIR); #else char tmp[MAXPATHLEN]; char *ospath = OsPath(path, tmp); statstruct buf; #ifdef __ANDROID__ if (Yap_isAsset(ospath)) { return Yap_AssetIsDir(ospath); } #endif if ( statfunc(ospath, &buf) < 0 ) return FALSE; if ( S_ISDIR(buf.st_mode) ) return TRUE; return FALSE; #endif /*O_XOS*/ }
static PyObject* LPX_getspecstatus(LPXObject *self, int(*statfunc)(LPX*)) { return glpstatus2string(statfunc(LP)); }
static int LastModifiedFile64(const char *name, int64_t *tp) { #ifdef __WINDOWS__ HANDLE hFile; wchar_t wfile[MAXPATHLEN]; #define nano * 0.000000001 #define ntick 100.0 #define SEC_TO_UNIX_EPOCH 11644473600.0 if ( !_xos_os_filenameW(name, wfile, MAXPATHLEN) ) return FALSE; if ( (hFile=CreateFileW(wfile, 0, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL)) != INVALID_HANDLE_VALUE ) { FILETIME wt; int rc; rc = GetFileTime(hFile, NULL, NULL, (FILETIME *)&wt); CloseHandle(hFile); if ( rc ) { LARGE_INTEGER date, adjust; date.HighPart = wt.dwHighDateTime; date.LowPart = wt.dwLowDateTime; adjust.QuadPart = 11644473600000 * 10000; date.QuadPart -= adjust.QuadPart; date.QuadPart /= 10000000; *tp = date.QuadPart; return TRUE; } } set_posix_error(GetLastError()); return FALSE; #else char tmp[MAXPATHLEN]; statstruct buf; #ifdef __ANDROID__ if (Yap_isAsset(name)) { if ( statfunc(OsPath("/", tmp), &buf) < 0 ) { return FALSE; } *tp = (int64_t)buf.st_mtime; return Yap_AccessAsset(name, R_OK); } #endif if ( statfunc(OsPath(name, tmp), &buf) < 0 ){ return FALSE; } *tp = (int64_t)buf.st_mtime; return TRUE; #endif }