Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 90880 invoked by uid 500); 10 Feb 2002 10:14:36 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 90854 invoked from network); 10 Feb 2002 10:14:35 -0000 From: "Jay Freeman \(saurik\)" To: "apr-dev" Subject: [PATCH] file_io\win32\filestat.c : implement apr_file_attrs_set() Date: Sun, 10 Feb 2002 04:14:34 -0600 Organization: Eschaton Entertainment Message-ID: <004c01c1b21b$bcda5190$fb590644@cruiser> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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; +}