harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r593252 - /harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
Date Thu, 08 Nov 2007 18:48:05 GMT
Author: ayza
Date: Thu Nov  8 10:48:03 2007
New Revision: 593252

URL: http://svn.apache.org/viewvc?rev=593252&view=rev
Log:
Handling of names for system devices was imporved. See HARMONY-5064.

Modified:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c?rev=593252&r1=593251&r2=593252&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
Thu Nov  8 10:48:03 2007
@@ -352,21 +352,25 @@
 /**
  * Determines if the given file name is a reserved device name
   
- * @param[in] fname file name
+ * @param[in] path the path
  * @return length of device name if given file name is a device name or
  *   0 otherwise 
  */
 int
-is_device_name(const char *fname)
+is_device_name(const char *path)
 {
     const char *reserved[] = {"con", "prn", "aux", "nul", "com", "lpt"};
-    int i, len = strlen(fname);
+    char *fname = strrchr(path, '\\');
+    int i, len;
+
+    fname = fname ? (fname + 1) : (char *) path;
+    len = strlen(fname);
     
     for (i = 0; i < 6; i++) {
-        if (i < 4 && len >= 3 && !_stricmp(fname + len - 3, reserved[i]))
{
+        if (i < 4 && len == 3 && !_stricmp(fname, reserved[i])) {
             return 3;
-        } else if (len >= 4 && !_strnicmp(fname + len - 4, reserved[i], 3) &&
-                   isdigit(fname[len - 1])) {
+        } else if (i >= 4 && len == 4 && !_strnicmp(fname, reserved[i],
3) &&
+                   isdigit(fname[3]) && fname[3] != '0') {
             return 4;
         }
     }



Mime
View raw message