Fix error handling UNC path

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28145 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-03-29 07:32:11 +00:00
parent 949e492513
commit 3452a47317
3 changed files with 32 additions and 19 deletions

View file

@ -1,3 +1,7 @@
2009-03-29 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSString.m: Fix error in parsing root of UNC path
2009-03-28 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSocketPort.m (-receivedEvent:...forMode:): Fix usage of

View file

@ -29,10 +29,17 @@
systems) requires some care. A modern operating system uses the concept
of a single root to the filesystem, but mswindows has multiple filesystems
with no common root, so code must be aware of this. There is also the
more minor issue that windows uses a backslash as a separator between
the components of a path and unix-like systems use a forward slash.
more minor issue that windows often uses a backslash as a separator between
the components of a path and unix-like systems always use forward slash.<br />
On windows there is also the issue that two styles of path are used,
most commonly with a drive letter and a path on that drive
(eg. 'C:\directory\file') but also UNC paths
(eg. '//host/share/directory/file') so path handling functions must deal
with both formats.
</p>
<p>GNUstep has three path handling modes, 'gnustep', 'unix', and 'windows'.
The mode defaults to 'gnustep' but may be set using the GSPathHandling()
function.<br />
You should probably stick to using the default 'gnustep' mode in which the
path handling methods cope with both unix and windows style paths in
portable and tolerant manner:<br />
@ -45,7 +52,11 @@
The path handling methods add forward slashes when building new paths
internally or when standardising paths, so those path strings provide
a portable representation (as long as they are relative paths, not including
system specific roots).
system specific roots).<br />
An important case to note is that on windows a path which looks at first
glance like an absolute path may actually be a relative one.<br />
'C:file' is a relative path because it specifies a file on the C drive
but does not say what directory it is in.
</p>
</chapter>
*/
@ -530,17 +541,17 @@ typedef NSUInteger NSStringEncodingConversionOptions;
* without alteration.<br />
* See -lastPathComponent for a definition of a path component.
* <example>
* @"hello/there" produces @"hello"
* @"hello" produces @""
* @"/hello" produces @"/"
* @"/" produces @"/"
* @"C:file" produces @"C:"
* @"C:" produces @"C:"
* @"C:/file" produces @"C:/"
* @"C:/" produces @"C:/"
* @"//host/share/file" produces @"//host/share/"
* @"//host/share/" produces @"/host/share/"
* @"//host/share" produces @"/host/share"
* @"hello/there" produces @"hello" (a relative path)
* @"hello" produces @"" (a relative path)
* @"/hello" produces @"/" (an absolute unix path)
* @"/" produces @"/" (an absolute unix path)
* @"C:file" produces @"C:" (a relative windows path)
* @"C:" produces @"C:" (a relative windows path)
* @"C:/file" produces @"C:/" (an absolute windows path)
* @"C:/" produces @"C:/" (an absolute windows path)
* @"//host/share/file" produces @"//host/share/" (a UNC path)
* @"//host/share/" produces @"//host/share/" (a UNC path)
* @"//path/file" produces @"//path" (an absolute Unix path)
* </example>
*/
- (NSString*) stringByDeletingLastPathComponent;

View file

@ -351,7 +351,6 @@ pathSepString()
* 'C:/' absolute root for a drive on windows
* 'C:' if entire path is 'C:' or 'C:relativepath'
* '//host/share/' absolute root for a host and share on windows
* '//host/share' if entire path is '//host/share'
* '~/' home directory for user
* '~' if entire path is '~'
* '~username/' home directory for user
@ -440,13 +439,12 @@ static unsigned rootOf(NSString *s, unsigned l)
*/
if (range.location > pos)
{
/* OK ... we have the '//host/share/'
* format, so this is a valid UNC path.
*/
root = NSMaxRange(range);
}
}
else
{
root = l;
}
}
}
}