You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2003/05/24 12:30:41 UTC
cvs commit: apr CHANGES
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.
Re: cvs commit: apr CHANGES
Posted by Branko Čibej <br...@xbc.nu>.
William A. Rowe, Jr. wrote:
>I don't remember discussion of this on dev@apr? Work/life/family
>have been insane, so I could have missed it.
>
There wasn't one, at least not recently. I simply followed the design
that was there, adding another flag.
>One of the 'good things' (tm) of APR is that we should be providing
>identical behavior across platforms, without the programmer having
>to go through platform choices. Now, some platforms provide that
>any arbitrary file can be hidden, and I suppose it's goodness to be
>able to create such files hidden, read only (advisory), etc.
>
>But wouldn't it be more effective if we found a way to abstract the
>'dot file' concept from unix, such that those files would be automatically
>hidden files on Win32/OS2/Netware? E.g. a file such as '.myfile', starting
>with a period, would be tagged as hidden on those platforms that don't
>provide the dot construct?
>
I wondered about that myself. But there are lots of semantic differences
between .foo on *nix and a hidden foo on DOS derivatives.
>I understand that SVN and some other apps want some granular
>control. But your patch doesn't offer any APR_HAVE_HIDDEN_FILE
>flags. Taking my theme above, we also might want to have
>APR_HAVE_DOT_FILE_HIDDEN or something like that.
>
>Thoughts?
>
That's not such a bad idea, really. We'd have to add similar flags for
executable (which doesn't exist at all on Windows or OS/2), and perhaps
whether read-only is a flag or a permission state, etc.
I know the apr_file_attrs_set interface was put together in a bit of a
rush. I'm happy with it the way it is now, but it might not be the best
way to do things. So, if we decide to add all sorts of flags, we might
thing about the function itself, and whether it needs changes.
--
Brane Čibej <br...@xbc.nu> http://www.xbc.nu/brane/
Re: cvs commit: apr CHANGES
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
I don't remember discussion of this on dev@apr? Work/life/family
have been insane, so I could have missed it.
One of the 'good things' (tm) of APR is that we should be providing
identical behavior across platforms, without the programmer having
to go through platform choices. Now, some platforms provide that
any arbitrary file can be hidden, and I suppose it's goodness to be
able to create such files hidden, read only (advisory), etc.
But wouldn't it be more effective if we found a way to abstract the
'dot file' concept from unix, such that those files would be automatically
hidden files on Win32/OS2/Netware? E.g. a file such as '.myfile', starting
with a period, would be tagged as hidden on those platforms that don't
provide the dot construct?
I understand that SVN and some other apps want some granular
control. But your patch doesn't offer any APR_HAVE_HIDDEN_FILE
flags. Taking my theme above, we also might want to have
APR_HAVE_DOT_FILE_HIDDEN or something like that.
Thoughts?
Bill
>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.
>
> --- 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 */