mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
More tweaks to isAbsolute
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21023 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
448b62767d
commit
8f0bd54874
3 changed files with 37 additions and 20 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
* Source/NSString.m: (isAbsolutePath) always treat a path beginning
|
||||
with '/' as absolute except when in windows mode or on windows and
|
||||
not in unix mode.
|
||||
not in unix mode. Treat all UNC paths as absolute ... a change made
|
||||
after a lot of trawling the web and looking at examples of UNC path
|
||||
usage.
|
||||
|
||||
2005-03-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -539,9 +539,9 @@ enum {
|
|||
* Returns NO otherwise.<br />
|
||||
* An absolute path in unix mode is one which begins
|
||||
* with a slash or tilde.<br />
|
||||
* In windows mode a drive specification (eg C:) or a UNC server and share
|
||||
* (eg //host/share) followed by a slash or backslash, is an absolute path,
|
||||
* as is any path beginning with a tilde.<br />
|
||||
* In windows mode a drive specification (eg C:) followed by a slash or
|
||||
* backslash, is an absolute path, as is any path beginning with a tilde.<br />
|
||||
* In any mode a UNC path (//host/share...) is always absolute.<br />
|
||||
* In gnustep path handling mode, the rules are the same as for windows,
|
||||
* except that a path whose root is a slash denotes an absolute path
|
||||
* when running on unix and a relative path when running under windows.
|
||||
|
|
|
@ -4405,34 +4405,49 @@ static NSFileManager *fm = nil;
|
|||
|
||||
if (l == 0)
|
||||
{
|
||||
return NO; // Empty string ... not absolute
|
||||
return NO; // Empty string ... relative
|
||||
}
|
||||
c = [self characterAtIndex: 0];
|
||||
if (c == (unichar)'~')
|
||||
{
|
||||
return YES; // Begins with tilde ... absolute
|
||||
}
|
||||
#if !defined(__MINGW__)
|
||||
if (c == '/' && GSPathHandlingWindows() == NO)
|
||||
{
|
||||
return YES; // Begins with slash ... absolute on unix.
|
||||
}
|
||||
#endif
|
||||
root = rootOf(self, l);
|
||||
if (root > 0 && pathSepMember([self characterAtIndex: root-1]))
|
||||
|
||||
/*
|
||||
* Any string beginning with '/' is absolute ... except in windows mode
|
||||
* or on windows and not in unix mode.
|
||||
*/
|
||||
if (c == '/')
|
||||
{
|
||||
#if defined(__MINGW__)
|
||||
if (root == 1 && GSPathHandlingUnix() == NO)
|
||||
if (GSPathHandlingUnix() == YES)
|
||||
{
|
||||
return NO; // Single slash/backslash is not absolute.
|
||||
return YES;
|
||||
}
|
||||
#else
|
||||
if (GSPathHandlingWindows() == NO)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
if (root == 1 && c == '\\')
|
||||
{
|
||||
return NO; // Single backslash is not absolute
|
||||
}
|
||||
return YES; // Root ends with separator ... absolute.
|
||||
}
|
||||
|
||||
/*
|
||||
* Any root over two characters long must be a drive specification with a
|
||||
* slash (absolute) or a UNC path (always absolute).
|
||||
*/
|
||||
root = rootOf(self, l);
|
||||
if (root > 2)
|
||||
{
|
||||
return YES; // UNC or C:/ ... absolute
|
||||
}
|
||||
|
||||
/*
|
||||
* What we have left are roots of the form 'C:' or '\' or a path
|
||||
* with no root, or a '/' (in windows mode only sence we already
|
||||
* handled a single slash in unix mode) ...
|
||||
* all these cases are relative paths.
|
||||
*/
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue