diff options
| author | Eli Zaretskii | 2013-11-16 14:59:26 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-11-16 14:59:26 +0200 |
| commit | 44b322511dfa8af002e92fc2a335065f4ac8e033 (patch) | |
| tree | dae6e72202de2dc1f4ae401d9ddf803a9e99b9fb /src | |
| parent | 6349f70a31a56fbaf8b5dbcaaddf624d137f9d63 (diff) | |
| download | emacs-44b322511dfa8af002e92fc2a335065f4ac8e033.tar.gz emacs-44b322511dfa8af002e92fc2a335065f4ac8e033.zip | |
Converted sys_mkdir and sys_open.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 47 |
1 files changed, 39 insertions, 8 deletions
| @@ -3731,7 +3731,22 @@ sys_link (const char * old, const char * new) | |||
| 3731 | int | 3731 | int |
| 3732 | sys_mkdir (const char * path) | 3732 | sys_mkdir (const char * path) |
| 3733 | { | 3733 | { |
| 3734 | return _mkdir (map_w32_filename (path, NULL)); | 3734 | path = map_w32_filename (path, NULL); |
| 3735 | |||
| 3736 | if (w32_unicode_filenames) | ||
| 3737 | { | ||
| 3738 | wchar_t path_w[MAX_PATH]; | ||
| 3739 | |||
| 3740 | filename_to_utf16 (path, path_w); | ||
| 3741 | return _wmkdir (path_w); | ||
| 3742 | } | ||
| 3743 | else | ||
| 3744 | { | ||
| 3745 | char path_a[MAX_PATH]; | ||
| 3746 | |||
| 3747 | filename_to_ansi (path, path_a); | ||
| 3748 | return _mkdir (path_a); | ||
| 3749 | } | ||
| 3735 | } | 3750 | } |
| 3736 | 3751 | ||
| 3737 | int | 3752 | int |
| @@ -3740,13 +3755,29 @@ sys_open (const char * path, int oflag, int mode) | |||
| 3740 | const char* mpath = map_w32_filename (path, NULL); | 3755 | const char* mpath = map_w32_filename (path, NULL); |
| 3741 | int res = -1; | 3756 | int res = -1; |
| 3742 | 3757 | ||
| 3743 | /* If possible, try to open file without _O_CREAT, to be able to | 3758 | if (w32_unicode_filenames) |
| 3744 | write to existing hidden and system files. Force all file | 3759 | { |
| 3745 | handles to be non-inheritable. */ | 3760 | wchar_t mpath_w[MAX_PATH]; |
| 3746 | if ((oflag & (_O_CREAT | _O_EXCL)) != (_O_CREAT | _O_EXCL)) | 3761 | |
| 3747 | res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | 3762 | filename_to_utf16 (mpath, mpath_w); |
| 3748 | if (res < 0) | 3763 | /* If possible, try to open file without _O_CREAT, to be able to |
| 3749 | res = _open (mpath, oflag | _O_NOINHERIT, mode); | 3764 | write to existing hidden and system files. Force all file |
| 3765 | handles to be non-inheritable. */ | ||
| 3766 | if ((oflag & (_O_CREAT | _O_EXCL)) != (_O_CREAT | _O_EXCL)) | ||
| 3767 | res = _wopen (mpath_w, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | ||
| 3768 | if (res < 0) | ||
| 3769 | res = _wopen (mpath_w, oflag | _O_NOINHERIT, mode); | ||
| 3770 | } | ||
| 3771 | else | ||
| 3772 | { | ||
| 3773 | char mpath_a[MAX_PATH]; | ||
| 3774 | |||
| 3775 | filename_to_ansi (mpath, mpath_a); | ||
| 3776 | if ((oflag & (_O_CREAT | _O_EXCL)) != (_O_CREAT | _O_EXCL)) | ||
| 3777 | res = _open (mpath_a, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | ||
| 3778 | if (res < 0) | ||
| 3779 | res = _open (mpath_a, oflag | _O_NOINHERIT, mode); | ||
| 3780 | } | ||
| 3750 | 3781 | ||
| 3751 | return res; | 3782 | return res; |
| 3752 | } | 3783 | } |