diff options
| author | Gerd Moellmann | 2001-04-10 12:15:25 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-04-10 12:15:25 +0000 |
| commit | 302f0b29125675990ffd5825f6e6b9f9912cde84 (patch) | |
| tree | a8814adee583cb0a6a5db043cdb41ec8c430b189 /src | |
| parent | dbb70029168d42bdb3b2fd5ba0f232469074e245 (diff) | |
| download | emacs-302f0b29125675990ffd5825f6e6b9f9912cde84.tar.gz emacs-302f0b29125675990ffd5825f6e6b9f9912cde84.zip | |
(sys_open): Try to open file without _O_CREAT first, to be
able to write to hidden and system files. Make file handles
non-inheritable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API. | 1 | /* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API. |
| 2 | Copyright (C) 1994, 1995 Free Software Foundation, Inc. | 2 | Copyright (C) 1994, 1995, 2000, 2001 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
| @@ -1819,8 +1819,14 @@ sys_mktemp (char * template) | |||
| 1819 | int | 1819 | int |
| 1820 | sys_open (const char * path, int oflag, int mode) | 1820 | sys_open (const char * path, int oflag, int mode) |
| 1821 | { | 1821 | { |
| 1822 | /* Force all file handles to be non-inheritable. */ | 1822 | const char* mpath = map_w32_filename (path, NULL); |
| 1823 | return _open (map_w32_filename (path, NULL), oflag | _O_NOINHERIT, mode); | 1823 | /* Try to open file without _O_CREAT, to be able to write to hidden |
| 1824 | and system files. Force all file handles to be | ||
| 1825 | non-inheritable. */ | ||
| 1826 | int res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); | ||
| 1827 | if (res >= 0) | ||
| 1828 | return res; | ||
| 1829 | return _open (mpath, oflag | _O_NOINHERIT, mode); | ||
| 1824 | } | 1830 | } |
| 1825 | 1831 | ||
| 1826 | int | 1832 | int |