diff options
author | brane <brane@13f79535-47bb-0310-9956-ffa450edef68> | 2003-05-24 10:30:40 +0000 |
---|---|---|
committer | brane <brane@13f79535-47bb-0310-9956-ffa450edef68> | 2003-05-24 10:30:40 +0000 |
commit | 220c6e4ea2e1c9b1d02fd9e974f204d384b96e53 (patch) | |
tree | 90067c91c24065b31468e36ba1723786099d29df /file_io | |
parent | 2c468c984d461c5a699ad1e2c7677104bf752f72 (diff) | |
download | libapr-220c6e4ea2e1c9b1d02fd9e974f204d384b96e53.tar.gz |
Added flag APR_FILE_ATTR_HIDDEN for manipulating the "hidden" file
attribute on Windows and OS/2. Also changed the apr_file_attrs_set
implementations to not make any syscalls if the requested attributes
are not supported on the platform.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64510 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/netware/filestat.c | 5 | ||||
-rw-r--r-- | file_io/os2/filestat.c | 17 | ||||
-rw-r--r-- | file_io/unix/filestat.c | 5 | ||||
-rw-r--r-- | file_io/win32/filestat.c | 13 |
4 files changed, 39 insertions, 1 deletions
diff --git a/file_io/netware/filestat.c b/file_io/netware/filestat.c index 3bee79d4a..55512a912 100644 --- a/file_io/netware/filestat.c +++ b/file_io/netware/filestat.c @@ -152,6 +152,11 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, apr_status_t status; apr_finfo_t finfo; + /* Don't do anything if we can't handle the requested attributes */ + if (!(attr_mask & (APR_FILE_ATTR_READONLY + | APR_FILE_ATTR_EXECUTABLE))) + return APR_SUCCESS; + status = apr_stat(&finfo, fname, APR_FINFO_PROT, pool); if (!APR_STATUS_IS_SUCCESS(status)) return status; diff --git a/file_io/os2/filestat.c b/file_io/os2/filestat.c index 7797a26b4..747f6e9ce 100644 --- a/file_io/os2/filestat.c +++ b/file_io/os2/filestat.c @@ -219,8 +219,14 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, apr_pool_t *cont) { FILESTATUS3 fs3; - ULONG rc = DosQueryPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3)); + ULONG rc; + + /* 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; + rc = DosQueryPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3)); if (rc == 0) { ULONG old_attr = fs3.attrFile; @@ -233,6 +239,15 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, } } + if (attr_mask & APR_FILE_ATTR_HIDDEN) + { + if (attributes & APR_FILE_ATTR_HIDDEN) { + fs3.attrFile |= FILE_HIDDEN; + } else { + fs3.attrFile &= ~FILE_HIDDEN; + } + } + if (fs3.attrFile != old_attr) { rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0); } diff --git a/file_io/unix/filestat.c b/file_io/unix/filestat.c index 0e0236e6b..02a4df975 100644 --- a/file_io/unix/filestat.c +++ b/file_io/unix/filestat.c @@ -166,6 +166,11 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, apr_status_t status; apr_finfo_t finfo; + /* Don't do anything if we can't handle the requested attributes */ + if (!(attr_mask & (APR_FILE_ATTR_READONLY + | APR_FILE_ATTR_EXECUTABLE))) + return APR_SUCCESS; + status = apr_stat(&finfo, fname, APR_FINFO_PROT, pool); if (!APR_STATUS_IS_SUCCESS(status)) return status; diff --git a/file_io/win32/filestat.c b/file_io/win32/filestat.c index 903780ec3..91a7fc07a 100644 --- a/file_io/win32/filestat.c +++ b/file_io/win32/filestat.c @@ -703,6 +703,11 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, 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 { @@ -731,6 +736,14 @@ APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, flags &= ~FILE_ATTRIBUTE_READONLY; } + if (attr_mask & APR_FILE_ATTR_HIDDEN) + { + if (attributes & APR_FILE_ATTR_HIDDEN) + flags |= FILE_ATTRIBUTE_HIDDEN; + else + flags &= ~FILE_ATTRIBUTE_HIDDEN; + } + #if APR_HAS_UNICODE_FS IF_WIN_OS_IS_UNICODE { |