diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 80 |
1 files changed, 67 insertions, 13 deletions
| @@ -3365,7 +3365,22 @@ faccessat (int dirfd, const char * path, int mode, int flags) | |||
| 3365 | && (flags & AT_SYMLINK_NOFOLLOW) == 0) | 3365 | && (flags & AT_SYMLINK_NOFOLLOW) == 0) |
| 3366 | path = chase_symlinks (path); | 3366 | path = chase_symlinks (path); |
| 3367 | 3367 | ||
| 3368 | if ((attributes = GetFileAttributes (path)) == -1) | 3368 | if (w32_unicode_filenames) |
| 3369 | { | ||
| 3370 | wchar_t path_w[MAX_PATH]; | ||
| 3371 | |||
| 3372 | filename_to_utf16 (path, path_w); | ||
| 3373 | attributes = GetFileAttributesW (path_w); | ||
| 3374 | } | ||
| 3375 | else | ||
| 3376 | { | ||
| 3377 | char path_a[MAX_PATH]; | ||
| 3378 | |||
| 3379 | filename_to_ansi (path, path_a); | ||
| 3380 | attributes = GetFileAttributesA (path_a); | ||
| 3381 | } | ||
| 3382 | |||
| 3383 | if (attributes == -1) | ||
| 3369 | { | 3384 | { |
| 3370 | DWORD w32err = GetLastError (); | 3385 | DWORD w32err = GetLastError (); |
| 3371 | 3386 | ||
| @@ -3477,23 +3492,21 @@ sys_access (const char *fname, int mode) | |||
| 3477 | int | 3492 | int |
| 3478 | sys_chdir (const char * path) | 3493 | sys_chdir (const char * path) |
| 3479 | { | 3494 | { |
| 3480 | /* FIXME: Temporary. Also, figure out what to do with | 3495 | path = map_w32_filename (path, NULL); |
| 3481 | map_w32_filename, as the original code did this: | ||
| 3482 | _chdir(map_w32_filename (path, NULL)). */ | ||
| 3483 | if (w32_unicode_filenames) | 3496 | if (w32_unicode_filenames) |
| 3484 | { | 3497 | { |
| 3485 | wchar_t newdir[MAXPATHLEN]; | 3498 | wchar_t newdir_w[MAX_PATH]; |
| 3486 | 3499 | ||
| 3487 | if (filename_to_utf16 (path, newdir) == 0) | 3500 | if (filename_to_utf16 (path, newdir_w) == 0) |
| 3488 | return _wchdir (newdir); | 3501 | return _wchdir (newdir_w); |
| 3489 | return -1; | 3502 | return -1; |
| 3490 | } | 3503 | } |
| 3491 | else | 3504 | else |
| 3492 | { | 3505 | { |
| 3493 | char newdir[MAXPATHLEN]; | 3506 | char newdir_a[MAX_PATH]; |
| 3494 | 3507 | ||
| 3495 | if (filename_to_ansi (path, newdir) == 0) | 3508 | if (filename_to_ansi (path, newdir_a) == 0) |
| 3496 | return _chdir (path); | 3509 | return _chdir (newdir_a); |
| 3497 | return -1; | 3510 | return -1; |
| 3498 | } | 3511 | } |
| 3499 | } | 3512 | } |
| @@ -3502,13 +3515,40 @@ int | |||
| 3502 | sys_chmod (const char * path, int mode) | 3515 | sys_chmod (const char * path, int mode) |
| 3503 | { | 3516 | { |
| 3504 | path = chase_symlinks (map_w32_filename (path, NULL)); | 3517 | path = chase_symlinks (map_w32_filename (path, NULL)); |
| 3505 | return _chmod (path, mode); | 3518 | if (w32_unicode_filenames) |
| 3519 | { | ||
| 3520 | wchar_t path_w[MAX_PATH]; | ||
| 3521 | |||
| 3522 | filename_to_utf16 (path, path_w); | ||
| 3523 | return _wchmod (path_w, mode); | ||
| 3524 | } | ||
| 3525 | else | ||
| 3526 | { | ||
| 3527 | char path_a[MAX_PATH]; | ||
| 3528 | |||
| 3529 | filename_to_ansi (path, path_a); | ||
| 3530 | return _chmod (path_a, mode); | ||
| 3531 | } | ||
| 3506 | } | 3532 | } |
| 3507 | 3533 | ||
| 3508 | int | 3534 | int |
| 3509 | sys_creat (const char * path, int mode) | 3535 | sys_creat (const char * path, int mode) |
| 3510 | { | 3536 | { |
| 3511 | return _creat (map_w32_filename (path, NULL), mode); | 3537 | path = map_w32_filename (path, NULL); |
| 3538 | if (w32_unicode_filenames) | ||
| 3539 | { | ||
| 3540 | wchar_t path_w[MAX_PATH]; | ||
| 3541 | |||
| 3542 | filename_to_utf16 (path, path_w); | ||
| 3543 | return _wcreat (path_w, mode); | ||
| 3544 | } | ||
| 3545 | else | ||
| 3546 | { | ||
| 3547 | char path_a[MAX_PATH]; | ||
| 3548 | |||
| 3549 | filename_to_ansi (path, path_a); | ||
| 3550 | return _creat (path_a, mode); | ||
| 3551 | } | ||
| 3512 | } | 3552 | } |
| 3513 | 3553 | ||
| 3514 | FILE * | 3554 | FILE * |
| @@ -3548,7 +3588,21 @@ sys_fopen (const char * path, const char * mode) | |||
| 3548 | } | 3588 | } |
| 3549 | else break; | 3589 | else break; |
| 3550 | 3590 | ||
| 3551 | fd = _open (map_w32_filename (path, NULL), oflag | _O_NOINHERIT, 0644); | 3591 | path = map_w32_filename (path, NULL); |
| 3592 | if (w32_unicode_filenames) | ||
| 3593 | { | ||
| 3594 | wchar_t path_w[MAX_PATH]; | ||
| 3595 | |||
| 3596 | filename_to_utf16 (path, path_w); | ||
| 3597 | fd = _wopen (path_w, oflag | _O_NOINHERIT, 0644); | ||
| 3598 | } | ||
| 3599 | else | ||
| 3600 | { | ||
| 3601 | char path_a[MAX_PATH]; | ||
| 3602 | |||
| 3603 | filename_to_ansi (path, path_a); | ||
| 3604 | fd = _open (path_a, oflag | _O_NOINHERIT, 0644); | ||
| 3605 | } | ||
| 3552 | if (fd < 0) | 3606 | if (fd < 0) |
| 3553 | return NULL; | 3607 | return NULL; |
| 3554 | 3608 | ||