274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
created = 1;
}
return !created;
}
/*
** Check if symlinks are potentially supported on the current OS.
** Theoretically this code should work on any NT based version of windows
** but I have no way of testing that. The initial check for
** IsWindowsVistaOrGreater() should in theory eliminate any system prior to
** Windows Vista, but I have no way to test that at this time.
** Return 1 if supported, 0 if not.
*/
int win32_symlinks_supported(){
TOKEN_PRIVILEGES tp;
LUID luid;
HANDLE process, token;
DWORD status;
/* symlinks only supported on vista or greater */
if (!IsWindowsVistaOrGreater())
return 0;
/* next we need to check to see if the privilege is available */
|
|
|
>
>
>
>
>
>
|
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
created = 1;
}
return !created;
}
/*
** Check if symlinks are potentially supported on the current OS for the given file.
** Theoretically this code should work on any NT based version of windows
** but I have no way of testing that. The initial check for
** IsWindowsVistaOrGreater() should in theory eliminate any system prior to
** Windows Vista, but I have no way to test that at this time.
** Return 1 if supported, 0 if not.
*/
int win32_symlinks_supported(const char* zFilename){
TOKEN_PRIVILEGES tp;
LUID luid;
HANDLE process, token;
DWORD status;
int success;
wchar_t *pFilename;
wchar_t fullName[MAX_PATH+1];
DWORD fullLength;
wchar_t volName[MAX_PATH+1];
DWORD fsFlags;
/* symlinks only supported on vista or greater */
if (!IsWindowsVistaOrGreater())
return 0;
/* next we need to check to see if the privilege is available */
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
status = GetLastError();
CloseHandle(token);
/* any error means we failed to enable the privilege, symlinks not supported */
if (status != ERROR_SUCCESS)
return 0;
/* we made it this far, symlinks must be supported */
return 1;
}
/*
** Wrapper around the access() system call. This code was copied from Tcl
** 8.6 and then modified.
*/
int win32_access(const wchar_t *zFilename, int flags){
|
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
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
360
361
362
|
status = GetLastError();
CloseHandle(token);
/* any error means we failed to enable the privilege, symlinks not supported */
if (status != ERROR_SUCCESS)
return 0;
/* assume no support for symlinks */
success = 0;
pFilename = fossil_utf8_to_filename(zFilename);
/* given the filename we're interested in, symlinks are supported if */
/* 1. we can get the full name of the path from the given path */
fullLength = GetFullPathNameW(pFilename, sizeof(fullName), fullName, NULL);
if ((fullLength > 0) && (fullLength < sizeof(fullName))){
/* 2. we can get the volume path name from the full name */
if (GetVolumePathNameW(fullName, volName, sizeof(volName))){
/* 3. we can get volume information from the volume path name */
if (GetVolumeInformationW(volName, NULL, 0, NULL, NULL, &fsFlags, NULL, 0)){
/* 4. the given volume support reparse points */
if (fsFlags & FILE_SUPPORTS_REPARSE_POINTS){
/* all four conditions were true, so we support symlinks; success! */
success = 1;
}
}
}
}
fossil_filename_free(pFilename);
return success;
}
/*
** Wrapper around the access() system call. This code was copied from Tcl
** 8.6 and then modified.
*/
int win32_access(const wchar_t *zFilename, int flags){
|