commons-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=789634&view=rev
Log:
Implement fileId for Windows

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

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=789634&r1=789633&r2=789634&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 09:23:14 2009
@@ -781,3 +781,44 @@
     }
 }
 
+ACR_IO_EXPORT_DECLARE(jlong, File, inode0)(ACR_JNISTDARGS, jstring pathname)
+{
+    jlong rv = 0;
+    int   ex = EINVAL;
+
+    UNREFERENCED_O;
+    WITH_WSTR(pathname) {
+        HANDLE fh;
+        FS2BS(J2W(pathname));
+
+        fh = CreateFileW(J2W(pathname),
+                        GENERIC_READ,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+                        NULL,
+                        OPEN_EXISTING,
+                        0,
+                        NULL);
+        if (fh != INVALID_HANDLE_VALUE) {
+            BY_HANDLE_FILE_INFORMATION fi;
+            if (GetFileInformationByHandle(fh, &fi)) {
+                rv = (((jlong)fi.nFileIndexHigh + (jlong)fi.dwVolumeSerialNumber) <<
31) + fi.nFileIndexLow;
+                ex = 0;
+            }
+            else
+                ex = ACR_GET_OS_ERROR();
+            CloseHandle(fh);
+        }
+        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 rv;
+}



Mime
View raw message