commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r813507 - /commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
Date Thu, 10 Sep 2009 16:40:50 GMT
Author: mturk
Date: Thu Sep 10 16:40:48 2009
New Revision: 813507

URL: http://svn.apache.org/viewvc?rev=813507&view=rev
Log:
Use internal basename

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/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=813507&r1=813506&r2=813507&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:40:48 2009
@@ -21,6 +21,7 @@
 #include "acr_string.h"
 #include "acr_descriptor.h"
 #include "acr_file.h"
+#include "acr_port.h"
 
 /**
  * Posix file functions
@@ -422,7 +423,7 @@
     UNREFERENCED_O;
 
     WITH_CSTR(pathname) {
-        char *sep;
+        char base[PATH_MAX] = "";
         int protection = ACR_FileProtectionGet(_E, J2S(pathname));
         if (protection > 0) {
             if ((protection & ACR_FPROT_UWRITE) != ACR_FPROT_UWRITE)
@@ -432,16 +433,10 @@
             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
-             */
-            if (*(sep + 1) == '.')
+        if (basename_r(J2S(pathname), base, PATH_MAX)) {
+            if (base[0] == '.')
                 attr |= ACR_FILE_ATTR_HIDDEN;
         }
-        else if (*J2S(pathname) == '.')
-            attr |= ACR_FILE_ATTR_HIDDEN;
     } END_WITH_CSTR(pathname);
 
     return attr;



Mime
View raw message