diff options
Diffstat (limited to 'file_io/win32/filestat.c')
-rw-r--r-- | file_io/win32/filestat.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c index cb0a32595..45dd7604d 100644 --- a/file_io/win32/filestat.c +++ b/file_io/win32/filestat.c @@ -793,68 +793,50 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, apr_fileattrs_t attr_mask, apr_pool_t *pool) { - DWORD flags; + DWORD old_flags; + DWORD new_flags; apr_status_t rv; -#if APR_HAS_UNICODE_FS apr_wchar_t wfname[APR_PATH_MAX]; -#endif /* Don't do anything if we can't handle the requested attributes */ if (!(attr_mask & (APR_FILE_ATTR_READONLY | APR_FILE_ATTR_HIDDEN))) return APR_SUCCESS; -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - if ((rv = utf8_to_unicode_path(wfname, - sizeof(wfname) / sizeof(wfname[0]), - fname))) - return rv; - flags = GetFileAttributesW(wfname); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - flags = GetFileAttributesA(fname); - } -#endif + if ((rv = utf8_to_unicode_path(wfname, + sizeof(wfname) / sizeof(wfname[0]), + fname))) + return rv; - if (flags == 0xFFFFFFFF) + old_flags = GetFileAttributesW(wfname); + if (old_flags == 0xFFFFFFFF) return apr_get_os_error(); + new_flags = old_flags; if (attr_mask & APR_FILE_ATTR_READONLY) { if (attributes & APR_FILE_ATTR_READONLY) - flags |= FILE_ATTRIBUTE_READONLY; + new_flags |= FILE_ATTRIBUTE_READONLY; else - flags &= ~FILE_ATTRIBUTE_READONLY; + new_flags &= ~FILE_ATTRIBUTE_READONLY; } if (attr_mask & APR_FILE_ATTR_HIDDEN) { if (attributes & APR_FILE_ATTR_HIDDEN) - flags |= FILE_ATTRIBUTE_HIDDEN; + new_flags |= FILE_ATTRIBUTE_HIDDEN; else - flags &= ~FILE_ATTRIBUTE_HIDDEN; + new_flags &= ~FILE_ATTRIBUTE_HIDDEN; } -#if APR_HAS_UNICODE_FS - IF_WIN_OS_IS_UNICODE - { - rv = SetFileAttributesW(wfname, flags); - } -#endif -#if APR_HAS_ANSI_FS - ELSE_WIN_OS_IS_ANSI - { - rv = SetFileAttributesA(fname, flags); + /* Don't do anything if we are not going to change attributes. */ + if (new_flags == old_flags) { + return APR_SUCCESS; } -#endif - if (rv == 0) + if (!SetFileAttributesW(wfname, new_flags)) { return apr_get_os_error(); + } return APR_SUCCESS; } |