mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
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:
parent
39ad1c53d8
commit
cfd9c1205f
3 changed files with 32 additions and 19 deletions
|
@ -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>
|
2009-03-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSSocketPort.m (-receivedEvent:...forMode:): Fix usage of
|
* Source/NSSocketPort.m (-receivedEvent:...forMode:): Fix usage of
|
||||||
|
|
|
@ -29,10 +29,17 @@
|
||||||
systems) requires some care. A modern operating system uses the concept
|
systems) requires some care. A modern operating system uses the concept
|
||||||
of a single root to the filesystem, but mswindows has multiple filesystems
|
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
|
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
|
more minor issue that windows often uses a backslash as a separator between
|
||||||
the components of a path and unix-like systems use a forward slash.
|
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>
|
||||||
<p>GNUstep has three path handling modes, 'gnustep', 'unix', and 'windows'.
|
<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
|
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
|
path handling methods cope with both unix and windows style paths in
|
||||||
portable and tolerant manner:<br />
|
portable and tolerant manner:<br />
|
||||||
|
@ -45,7 +52,11 @@
|
||||||
The path handling methods add forward slashes when building new paths
|
The path handling methods add forward slashes when building new paths
|
||||||
internally or when standardising paths, so those path strings provide
|
internally or when standardising paths, so those path strings provide
|
||||||
a portable representation (as long as they are relative paths, not including
|
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>
|
</p>
|
||||||
</chapter>
|
</chapter>
|
||||||
*/
|
*/
|
||||||
|
@ -530,17 +541,17 @@ typedef NSUInteger NSStringEncodingConversionOptions;
|
||||||
* without alteration.<br />
|
* without alteration.<br />
|
||||||
* See -lastPathComponent for a definition of a path component.
|
* See -lastPathComponent for a definition of a path component.
|
||||||
* <example>
|
* <example>
|
||||||
* @"hello/there" produces @"hello"
|
* @"hello/there" produces @"hello" (a relative path)
|
||||||
* @"hello" produces @""
|
* @"hello" produces @"" (a relative path)
|
||||||
* @"/hello" produces @"/"
|
* @"/hello" produces @"/" (an absolute unix path)
|
||||||
* @"/" produces @"/"
|
* @"/" produces @"/" (an absolute unix path)
|
||||||
* @"C:file" produces @"C:"
|
* @"C:file" produces @"C:" (a relative windows path)
|
||||||
* @"C:" produces @"C:"
|
* @"C:" produces @"C:" (a relative windows path)
|
||||||
* @"C:/file" produces @"C:/"
|
* @"C:/file" produces @"C:/" (an absolute windows path)
|
||||||
* @"C:/" produces @"C:/"
|
* @"C:/" produces @"C:/" (an absolute windows path)
|
||||||
* @"//host/share/file" produces @"//host/share/"
|
* @"//host/share/file" produces @"//host/share/" (a UNC path)
|
||||||
* @"//host/share/" produces @"/host/share/"
|
* @"//host/share/" produces @"//host/share/" (a UNC path)
|
||||||
* @"//host/share" produces @"/host/share"
|
* @"//path/file" produces @"//path" (an absolute Unix path)
|
||||||
* </example>
|
* </example>
|
||||||
*/
|
*/
|
||||||
- (NSString*) stringByDeletingLastPathComponent;
|
- (NSString*) stringByDeletingLastPathComponent;
|
||||||
|
|
|
@ -351,7 +351,6 @@ pathSepString()
|
||||||
* 'C:/' absolute root for a drive on windows
|
* 'C:/' absolute root for a drive on windows
|
||||||
* 'C:' if entire path is 'C:' or 'C:relativepath'
|
* 'C:' if entire path is 'C:' or 'C:relativepath'
|
||||||
* '//host/share/' absolute root for a host and share on windows
|
* '//host/share/' absolute root for a host and share on windows
|
||||||
* '//host/share' if entire path is '//host/share'
|
|
||||||
* '~/' home directory for user
|
* '~/' home directory for user
|
||||||
* '~' if entire path is '~'
|
* '~' if entire path is '~'
|
||||||
* '~username/' home directory for user
|
* '~username/' home directory for user
|
||||||
|
@ -440,13 +439,12 @@ static unsigned rootOf(NSString *s, unsigned l)
|
||||||
*/
|
*/
|
||||||
if (range.location > pos)
|
if (range.location > pos)
|
||||||
{
|
{
|
||||||
|
/* OK ... we have the '//host/share/'
|
||||||
|
* format, so this is a valid UNC path.
|
||||||
|
*/
|
||||||
root = NSMaxRange(range);
|
root = NSMaxRange(range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
root = l;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue