You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/06/30 16:17:11 UTC
svn commit: r789753 - in /commons/sandbox/runtime/trunk/src/main/native/os:
unix/file.c win32/file.c
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;
+}
+