commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r789753 - in /commons/sandbox/runtime/trunk/src/main/native/os: unix/file.c win32/file.c
Date Tue, 30 Jun 2009 14:17:11 GMT
Author: mturk
Date: Tue Jun 30 14:17:11 2009
New Revision: 789753

URL: http://svn.apache.org/viewvc?rev=789753&view=rev
Log:
Add getFileAttributes method

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=789753&r1=789752&r2=789753&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Tue Jun 30 14:17:11 2009
@@ -470,7 +470,7 @@
     WITH_CSTR(pathname) {
         char *sep;
         int protection = ACR_FileProtectionGet(_E, J2S(pathname));
-        if (protection >= 0) {
+        if (protection > 0) {
             if ((protection & ACR_FPROT_UWRITE) != ACR_FPROT_UWRITE)
                 attr |= ACR_FILE_ATTR_READONLY;
             if ((protection & (ACR_FPROT_UEXECUTE | ACR_FPROT_GEXECUTE | ACR_FPROT_WEXECUTE)))

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=789753&r1=789752&r2=789753&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Tue Jun 30 14:17:11 2009
@@ -822,3 +822,39 @@
     }
     return rv;
 }
+
+ACR_IO_EXPORT_DECLARE(int, File, attrg0)(ACR_JNISTDARGS, jstring pathname)
+{
+    int attr = 0;
+    int ex = 0;
+    DWORD flags;
+
+    UNREFERENCED_O;
+
+    WITH_WSTR(pathname) {
+        FS2BS(J2W(pathname));
+        flags = GetFileAttributesW(J2W(pathname));
+        if (flags != 0xFFFFFFFF) {
+            if ((flags & FILE_ATTRIBUTE_HIDDEN))
+                attr |= ACR_FILE_ATTR_HIDDEN;
+            if ((flags & FILE_ATTRIBUTE_READONLY)) {
+                attr |= ACR_FILE_ATTR_READONLY;
+                if (!(flags & FILE_ATTRIBUTE_HIDDEN))
+                    attr |= ACR_FILE_ATTR_EXECUTABLE;
+            }
+        }
+        else
+            ex = ACR_GET_OS_ERROR();
+    } END_WITH_WSTR(pathname);
+
+    if (ex) {
+        if (ACR_STATUS_IS_EACCES(ex)) {
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
+        }
+        else if (!ACR_STATUS_IS_EEXIST(ex)) {
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ex);
+        }
+    }
+    return attr;
+}
+



Mime
View raw message