brane 2003/05/24 03:30:40
Modified: include apr_file_io.h
file_io/win32 filestat.c
file_io/unix filestat.c
file_io/os2 filestat.c
file_io/netware filestat.c
. CHANGES
Log:
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.
Revision Changes Path
1.140 +2 -0 apr/include/apr_file_io.h
Index: apr_file_io.h
===================================================================
RCS file: /home/cvs/apr/include/apr_file_io.h,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- apr_file_io.h 1 May 2003 03:16:30 -0000 1.139
+++ apr_file_io.h 24 May 2003 10:30:39 -0000 1.140
@@ -129,6 +129,7 @@
/* flags for apr_file_attrs_set */
#define APR_FILE_ATTR_READONLY 0x01 /**< File is read-only */
#define APR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */
+#define APR_FILE_ATTR_HIDDEN 0x04 /**< File is hidden */
/** @} */
/** File attributes */
@@ -639,6 +640,7 @@
* <PRE>
* APR_FILE_ATTR_READONLY - make the file readonly
* APR_FILE_ATTR_EXECUTABLE - make the file executable
+ * APR_FILE_ATTR_HIDDEN - make the file hidden
* </PRE>
* @param attr_mask Mask of valid bits in attributes.
* @param cont the pool to use.
1.80 +13 -0 apr/file_io/win32/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- filestat.c 19 May 2003 14:01:22 -0000 1.79
+++ filestat.c 24 May 2003 10:30:39 -0000 1.80
@@ -703,6 +703,11 @@
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
{
@@ -729,6 +734,14 @@
flags |= FILE_ATTRIBUTE_READONLY;
else
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
1.66 +5 -0 apr/file_io/unix/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/filestat.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- filestat.c 6 Mar 2003 09:21:24 -0000 1.65
+++ filestat.c 24 May 2003 10:30:39 -0000 1.66
@@ -166,6 +166,11 @@
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;
1.36 +16 -1 apr/file_io/os2/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/filestat.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- filestat.c 31 Mar 2003 12:31:40 -0000 1.35
+++ filestat.c 24 May 2003 10:30:40 -0000 1.36
@@ -219,8 +219,14 @@
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;
@@ -230,6 +236,15 @@
fs3.attrFile |= FILE_READONLY;
} else {
fs3.attrFile &= ~FILE_READONLY;
+ }
+ }
+
+ if (attr_mask & APR_FILE_ATTR_HIDDEN)
+ {
+ if (attributes & APR_FILE_ATTR_HIDDEN) {
+ fs3.attrFile |= FILE_HIDDEN;
+ } else {
+ fs3.attrFile &= ~FILE_HIDDEN;
}
}
1.29 +5 -0 apr/file_io/netware/filestat.c
Index: filestat.c
===================================================================
RCS file: /home/cvs/apr/file_io/netware/filestat.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- filestat.c 8 May 2003 16:44:08 -0000 1.28
+++ filestat.c 24 May 2003 10:30:40 -0000 1.29
@@ -152,6 +152,11 @@
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;
1.408 +3 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.407
retrieving revision 1.408
diff -u -r1.407 -r1.408
--- CHANGES 8 May 2003 08:51:02 -0000 1.407
+++ CHANGES 24 May 2003 10:30:40 -0000 1.408
@@ -1,5 +1,8 @@
Changes with APR 0.9.4
+ *) Added flag APR_FILE_ATTR_HIDDEN for manipulating the "hidden"
+ file attribute on Windows and OS/2. [Branko Cibej]
+
*) apr_proc_wait(): Handle interrupted waitpid(2) calls by calling
it repeatedly until it succeeds or fails with errno other than
EINTR. This hides this UNIX-specific behavior from APR clients.