You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Jay Freeman (saurik)" <sa...@saurik.com> on 2002/02/10 11:14:34 UTC
[PATCH] file_io\win32\filestat.c : implement apr_file_attrs_set()
I was trying to get the latest build of Subversion to work on Windows
today, and finally traced the problem to trying to use
apr_file_attrs_set(), which apparently isn't written for Windows yet.
In the hope of moving this along, I went ahead and wrote an
implementation for FILE_ATTRIBUTES_READONLY (there isn't really a good
corollary for EXECUTABLE...).
Latest Subversion still isn't working, but at least this puts things a
step closer...
Sincerely,
Jay Freeman (saurik)
saurik@saurik.com
Index: file_io/win32/filestat.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/filestat.c,v
retrieving revision 1.63
diff -u -r1.63 filestat.c
--- file_io/win32/filestat.c 7 Feb 2002 00:57:21 -0000 1.63
+++ file_io/win32/filestat.c 10 Feb 2002 10:08:44 -0000
@@ -622,5 +622,51 @@
apr_fileattrs_t
attributes,
apr_pool_t *cont)
{
- return APR_ENOTIMPL;
-}
+ DWORD flags;
+ apr_status_t rv;
+#if APR_HAS_UNICODE_FS
+ apr_wchar_t wfname[APR_PATH_MAX];
+#endif
+
+#if APR_HAS_UNICODE_FS
+ IF_WIN_OS_IS_UNICODE
+ {
+ if (rv = utf8_to_unicode_path(wfname, sizeof(wfname)
+ / sizeof(apr_wchar_t),
fname))
+ return rv;
+ flags = GetFileAttributesW(wfname);
+ }
+#endif
+#if APR_HAS_ANSI_FS
+ ELSE_WIN_OS_IS_ANSI
+ {
+ flags = GetFileAttributesA(fname);
+ }
+#endif
+
+ if (flags == -1)
+ return apr_get_os_error();
+
+ if (attributes & APR_FILE_ATTR_READONLY)
+ flags |= FILE_ATTRIBUTE_READONLY;
+ else
+ flags &= !FILE_ATTRIBUTE_READONLY;
+
+#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);
+ }
+#endif
+
+ if (rv == 0)
+ return apr_get_os_error();
+
+ return APR_SUCCESS;
+}
Re: [PATCH] file_io\win32\filestat.c : implement apr_file_attrs_set()
Posted by Branko Čibej <br...@xbc.nu>.
Jay Freeman (saurik) wrote:
>I was trying to get the latest build of Subversion to work on Windows
>today, and finally traced the problem to trying to use
>apr_file_attrs_set(), which apparently isn't written for Windows yet.
>In the hope of moving this along, I went ahead and wrote an
>implementation for FILE_ATTRIBUTES_READONLY (there isn't really a good
>corollary for EXECUTABLE...).
>
>Latest Subversion still isn't working, but at least this puts things a
>step closer...
>
Thanks, Jay. Applied, with two tiny little changes.
--
Brane Čibej <br...@xbc.nu> http://www.xbc.nu/brane/