bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug handling UNC pathes on windows in NSString.m/NSFileManager.m


From: Roland Schwingel
Subject: Bug handling UNC pathes on windows in NSString.m/NSFileManager.m
Date: Mon, 21 Jul 2003 14:38:43 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312

Hi...

There is a bug in gnustep-base of not being able to deal with UNC pathes correctly on windows.

Since a while all pathes are converted to an internal format, this applies especially for windows pathes. But the functions in NSString/NSFileManager dealing with this are having problems with direct UNC pathes...

So imagine a path  \\server\share\some\more\pathcomponents
Currently this is transformed to /server/share/some/more/pathcomponents if it is transformed back again it gets converted to \server\share\some\more\pathcomponents. Missing an initial backslash and nothing works anymore on windows.

My applied patch fixes this in NSString.m and NSFileManger.m by leaving an additional / in front of the internal representation.

Roland


--- NSFileManager.m.orig        2003-07-21 14:23:04.000000000 +0200
+++ NSFileManager.m     2003-07-18 16:44:15.000000000 +0200
@@ -1852,7 +1852,7 @@
       i = 0;
     }
   /*
-   * Convert backslashes to slashes, colaescing adjacent slashses.
+   * Convert backslashes to slashes, colaescing adjacent slashses, but 
preserve double // for UNC path
    * Also elide '/./' sequences, because we can do so efficiently.
    */
   j = i;
@@ -1860,7 +1860,7 @@
     {
       if (ptr[i] == '\\')
        {
-         if (j == 0 || buf[j-1] != '/')
+         if (j < 2 || buf[j-1] != '/')
            {
              if (j > 2 && buf[j-2] == '/' && buf[j-1] == '.')
                {
--- NSString.m.orig     2003-07-21 14:22:53.000000000 +0200
+++ NSString.m  2003-07-18 16:44:15.000000000 +0200
@@ -3367,6 +3367,7 @@
 {
   NSMutableString      *s;
   NSRange              r;
+  int                  length;
   unichar              (*caiImp)(NSString*, SEL, unsigned int);
 
   /* Expand `~' in the path */
@@ -3374,7 +3375,16 @@
   caiImp = (unichar (*)())[s methodForSelector: caiSel];
 
   /* Condense `//' and '/./' */
-  r = NSMakeRange(0, [s length]);
+  length = [s length];
+  r = NSMakeRange(0, length);
+#if defined(__MINGW__)
+  /* Skip first char on mingw to allow UNC Pathes */
+  if (length > 0)
+  {
+    r.location++;
+    r.length--;
+  }
+#endif
   while ((r = [s rangeOfCharacterFromSet: pathSeps()
                                 options: 0
                                   range: r]).length)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]