apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r592304 - in /apr/apr/trunk: file_io/win32/filestat.c include/arch/win32/apr_arch_misc.h
Date Tue, 06 Nov 2007 06:33:46 GMT
Author: wrowe
Date: Mon Nov  5 22:33:46 2007
New Revision: 592304

URL: http://svn.apache.org/viewvc?rev=592304&view=rev
Log:
Now in 1.3.0 a valid csize becomes very critical to enable
us to run the lfs sparse file tests.  Make this so on win32
where we have Win2k and later, at least by filename (since
it's documented that CompressedFileSize ~= allocation of
a sparse file, yet there is no way to know this by-handle.)

Modified:
    apr/apr/trunk/file_io/win32/filestat.c
    apr/apr/trunk/include/arch/win32/apr_arch_misc.h

Modified: apr/apr/trunk/file_io/win32/filestat.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/filestat.c?rev=592304&r1=592303&r2=592304&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filestat.c (original)
+++ apr/apr/trunk/file_io/win32/filestat.c Mon Nov  5 22:33:46 2007
@@ -188,7 +188,8 @@
     return rv;
 }
 
-static void guess_protection_bits(apr_finfo_t *finfo)
+static apr_status_t guess_protection_bits(apr_finfo_t *finfo,
+                                          apr_int32_t wanted)
 {
     /* Read, write execute for owner.  In the Win9x environment, any
      * readable file is executable (well, not entirely 100% true, but
@@ -205,6 +206,8 @@
                        | (finfo->protection << prot_scope_user);
 
     finfo->valid |= APR_FINFO_UPROT | APR_FINFO_GPROT | APR_FINFO_WPROT;
+
+    return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS);
 }
 
 apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile, 
@@ -215,8 +218,9 @@
     apr_status_t rv;
 
     if (apr_os_level < APR_WIN_NT)
-        guess_protection_bits(finfo);
-    else if (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))
+        return guess_protection_bits(finfo, wanted);
+
+    if (wanted & (APR_FINFO_PROT | APR_FINFO_OWNER))
     {
         /* On NT this request is incredibly expensive, but accurate.
          * Since the WinNT-only functions below are protected by the
@@ -286,9 +290,42 @@
             resolve_prot(finfo, wanted, dacl);
         }
         else if (wanted & APR_FINFO_PROT)
-            guess_protection_bits(finfo);
+            guess_protection_bits(finfo, wanted);
     }
 
+    if ((apr_os_level >= APR_WIN_2000) && (wanted & APR_FINFO_CSIZE)
+                                       && (finfo->filetype == APR_REG))
+    {
+        DWORD sizelo, sizehi;
+        if (whatfile == MORE_OF_HANDLE) {
+            /* Not available for development and implementation under
+             * a reasonable license; if you review the licensing
+             * terms and conditions of;
+             *   http://go.microsoft.com/fwlink/?linkid=84083
+             * you probably understand why APR chooses not to implement.
+             */
+            ;
+        }
+        else {
+            SetLastError(NO_ERROR);
+            if (whatfile == MORE_OF_WFSPEC)
+                sizelo = GetCompressedFileSizeW((apr_wchar_t*)ufile, &sizehi);
+            else if (whatfile == MORE_OF_FSPEC)
+                sizelo = GetCompressedFileSizeA((char*)ufile, &sizehi);
+        
+            if (sizelo != INVALID_FILE_SIZE || GetLastError() == NO_ERROR) {
+#if APR_HAS_LARGE_FILES
+                finfo->csize =  (apr_off_t)sizelo
+                             | ((apr_off_t)sizehi << 32);
+#else
+                finfo->csize = (apr_off_t)sizelo;
+                if (finfo->csize < 0 || sizehi)
+                    finfo->csize = 0x7fffffff;
+#endif
+                finfo->valid |= APR_FINFO_CSIZE;
+            }
+        }
+    }
     return ((wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS);
 }
 

Modified: apr/apr/trunk/include/arch/win32/apr_arch_misc.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/win32/apr_arch_misc.h?rev=592304&r1=592303&r2=592304&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/win32/apr_arch_misc.h (original)
+++ apr/apr/trunk/include/arch/win32/apr_arch_misc.h Mon Nov  5 22:33:46 2007
@@ -213,6 +213,7 @@
  */
 
 #if !defined(_WIN32_WCE) && !defined(WINNT)
+/* This group is available to all versions of WINNT 4.0 SP6 and later */
 
 #ifdef GetFileAttributesExA
 #undef GetFileAttributesExA
@@ -308,6 +309,30 @@
 #endif /* !defined(_WIN32_WCE) && !defined(WINNT) */
 
 #if !defined(_WIN32_WCE)
+/* This group is NOT available to all versions of WinNT,
+ * these we must always look up
+ */
+
+#ifdef GetCompressedFileSizeA
+#undef GetCompressedFileSizeA
+#endif
+APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, DWORD, WINAPI, GetCompressedFileSizeA, 0, (
+    IN LPCSTR lpFileName,
+    OUT LPDWORD lpFileSizeHigh),
+    (lpFileName, lpFileSizeHigh));
+#define GetCompressedFileSizeA apr_winapi_GetCompressedFileSizeA
+#undef GetCompressedFileSize
+#define GetCompressedFileSize apr_winapi_GetCompressedFileSizeA
+
+#ifdef GetCompressedFileSizeW
+#undef GetCompressedFileSizeW
+#endif
+APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, DWORD, WINAPI, GetCompressedFileSizeW, 0, (
+    IN LPCWSTR lpFileName,
+    OUT LPDWORD lpFileSizeHigh),
+    (lpFileName, lpFileSizeHigh));
+#define GetCompressedFileSizeW apr_winapi_GetCompressedFileSizeW
+
 
 APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryTimerResolution, 0, (
     ULONG *pMaxRes,  /* Minimum NS Resolution */



Mime
View raw message