45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
+
+
+
+
+
+
|
** The file status information from the most recent stat() call.
**
** Use _stati64 rather than stat on windows, in order to handle files
** larger than 2GB.
*/
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
# undef stat
# define stat _stati64
# define stat _fossil_stati64
struct stat {
i64 st_size;
i64 st_mtime;
int st_mode;
};
#endif
/*
** On Windows S_ISLNK always returns FALSE.
*/
#if !defined(S_ISLNK)
# define S_ISLNK(x) (0)
#endif
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
+
-
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
|
char *zMbcs = fossil_utf8_to_filename(zFilename);
if( isWd && g.allowSymlinks ){
rc = lstat(zMbcs, buf);
}else{
rc = stat(zMbcs, buf);
}
#else
WIN32_FILE_ATTRIBUTE_DATA attr;
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
if( memcmp(zMbcs, L"\\\\?\\", 8)==0 ){
rc = !GetFileAttributesExW(zMbcs, GetFileExInfoStandard, &attr);
/* Unfortunately, _wstati64 cannot handle extended prefixes. */
if( memcmp(zMbcs+4, "UNC\\", 8)==0 ){
zMbcs[6] = '\\';
rc = _wstati64(zMbcs+6, buf);
}else{
rc = _wstati64(zMbcs+4, buf);
if( !rc ){
ULARGE_INTEGER ull;
ull.LowPart = attr.ftLastWriteTime.dwLowDateTime;
ull.HighPart = attr.ftLastWriteTime.dwHighDateTime;
buf->st_mode = (attr.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)?
}
}else{
rc = _wstati64(zMbcs, buf);
S_IFDIR:S_IFREG;
buf->st_size = (((i64)attr.nFileSizeHigh)<<32) | buf->attr.nFileSizeLow;
buf->st_mtime = ull.QuadPart / 10000000ULL - 11644473600ULL;
}
#endif
fossil_filename_free(zMbcs);
return rc;
}
/*
|
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
|
/*
** Wrapper around the access() system call.
*/
int file_access(const char *zFilename, int flags){
#ifdef _WIN32
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
int rc;
if( memcmp(zMbcs, L"\\\\?\\", 8)==0 ){
/* Unfortunately, _waccess cannot handle extended prefixes. */
if( memcmp(zMbcs+4, "UNC\\", 8)==0 ){
zMbcs[6] = '\\';
rc = _waccess(zMbcs+6, flags);
}else{
rc = _waccess(zMbcs+4, flags);
}
}else{
int rc = _waccess(zMbcs, flags);
rc = _waccess(zMbcs, flags);
}
#else
char *zMbcs = fossil_utf8_to_filename(zFilename);
int rc = access(zMbcs, flags);
#endif
fossil_filename_free(zMbcs);
return rc;
}
/*
** Wrapper around the chdir() system call.
** If bChroot=1, do a chroot to this dir as well
** (UNIX only)
*/
int file_chdir(const char *zChDir, int bChroot){
#ifdef _WIN32
wchar_t *zPath = fossil_utf8_to_filename(zChDir);
int rc = _wchdir(zPath);
int rc = SetCurrentDirectoryW(zPath)==0;
#else
char *zPath = fossil_utf8_to_filename(zChDir);
int rc = chdir(zPath);
if( !rc && bChroot ){
rc = chroot(zPath);
if( !rc ) rc = chdir("/");
}
|