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/09/10 18:32:31 UTC
svn commit: r813500 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/io/FileAttributes.java
native/include/acr_file.h native/os/unix/file.c native/os/win32/file.c
Author: mturk
Date: Thu Sep 10 16:32:29 2009
New Revision: 813500
URL: http://svn.apache.org/viewvc?rev=813500&view=rev
Log:
Start fixing APR's file attributes API unusability
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h
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/java/org/apache/commons/runtime/io/FileAttributes.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java?rev=813500&r1=813499&r2=813500&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java Thu Sep 10 16:32:29 2009
@@ -23,12 +23,30 @@
*/
public enum FileAttributes
{
- /** File is read-only */
+ /** File is read-only.
+ */
READONLY( 0x01),
- /** File is executable */
+ /** File is executable.
+ */
EXECUTABLE( 0x02),
- /** File is hidden */
- HIDDEN( 0x04);
+ /** File is hidden.
+ * <p>
+ * On POSIX platforms this bit means that the file name starts with the
+ * dot (@code (.)} character which is usual way of representing the
+ * hidden files.
+ * On Windows platform it merely reflects the
+ * {@code hidden} file attribute.
+ * </p>
+ */
+ HIDDEN( 0x04),
+ /** File is reserved for system use only.
+ * <p>
+ * On POSIX platforms this bit means that the file has
+ * set UID bit set. On Windows platform it merely reflects the
+ * {@code system} file attribute.
+ * </p>
+ */
+ SYSTEM( 0x08);
private int value;
private FileAttributes(int v)
@@ -74,4 +92,3 @@
return set;
}
}
-
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h?rev=813500&r1=813499&r2=813500&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h Thu Sep 10 16:32:29 2009
@@ -119,6 +119,7 @@
#define ACR_FILE_ATTR_READONLY 0x01 /**< File is read-only */
#define ACR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */
#define ACR_FILE_ATTR_HIDDEN 0x04 /**< File is hidden */
+#define ACR_FILE_ATTR_SYSTEM 0x08 /**< File is system */
/** @} */
/* File lock types/flags */
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=813500&r1=813499&r2=813500&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 Thu Sep 10 16:32:29 2009
@@ -429,7 +429,11 @@
attr |= ACR_FILE_ATTR_READONLY;
if ((protection & (ACR_FPROT_UEXECUTE | ACR_FPROT_GEXECUTE | ACR_FPROT_WEXECUTE)))
attr |= ACR_FILE_ATTR_EXECUTABLE;
+ if ((protection & (ACR_FPROT_USETID | ACR_FPROT_GSETID)))
+ attr |= ACR_FILE_ATTR_SYSTEM;
}
+ /* TODO: Use basename for this
+ */
if ((sep = strrchr(J2S(pathname), '/')) != NULL) {
/* Presume dot files are hidden
*/
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=813500&r1=813499&r2=813500&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 Thu Sep 10 16:32:29 2009
@@ -852,11 +852,20 @@
if (flags != 0xFFFFFFFF) {
if ((flags & FILE_ATTRIBUTE_HIDDEN))
attr |= ACR_FILE_ATTR_HIDDEN;
+ else {
+ /* ###: Basically anything but directory
+ * is in theory executable
+ */
+ if (!(flags & (FILE_ATTRIBUTE_DIRECTORY |
+ FILE_ATTRIBUTE_SPARSE_FILE |
+ FILE_ATTRIBUTE_OFFLINE)))
+ attr |= ACR_FILE_ATTR_EXECUTABLE;
+ }
if ((flags & FILE_ATTRIBUTE_READONLY)) {
attr |= ACR_FILE_ATTR_READONLY;
- if (!(flags & FILE_ATTRIBUTE_HIDDEN))
- attr |= ACR_FILE_ATTR_EXECUTABLE;
}
+ if ((flags & FILE_ATTRIBUTE_SYSTEM))
+ attr |= ACR_FILE_ATTR_SYSTEM;
}
else
ex = ACR_GET_OS_ERROR();