mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
|
* Source/NSString.m: (isAbsolutePath) always treat a path beginning
|
||||||
with '/' as absolute except when in windows mode or on windows and
|
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>
|
2005-03-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -539,9 +539,9 @@ enum {
|
||||||
* Returns NO otherwise.<br />
|
* Returns NO otherwise.<br />
|
||||||
* An absolute path in unix mode is one which begins
|
* An absolute path in unix mode is one which begins
|
||||||
* with a slash or tilde.<br />
|
* with a slash or tilde.<br />
|
||||||
* In windows mode a drive specification (eg C:) or a UNC server and share
|
* In windows mode a drive specification (eg C:) followed by a slash or
|
||||||
* (eg //host/share) followed by a slash or backslash, is an absolute path,
|
* backslash, is an absolute path, as is any path beginning with a tilde.<br />
|
||||||
* 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,
|
* 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
|
* 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.
|
* when running on unix and a relative path when running under windows.
|
||||||
|
|
|
@ -4405,34 +4405,49 @@ static NSFileManager *fm = nil;
|
||||||
|
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
{
|
{
|
||||||
return NO; // Empty string ... not absolute
|
return NO; // Empty string ... relative
|
||||||
}
|
}
|
||||||
c = [self characterAtIndex: 0];
|
c = [self characterAtIndex: 0];
|
||||||
if (c == (unichar)'~')
|
if (c == (unichar)'~')
|
||||||
{
|
{
|
||||||
return YES; // Begins with tilde ... absolute
|
return YES; // Begins with tilde ... absolute
|
||||||
}
|
}
|
||||||
#if !defined(__MINGW__)
|
|
||||||
if (c == '/' && GSPathHandlingWindows() == NO)
|
/*
|
||||||
{
|
* Any string beginning with '/' is absolute ... except in windows mode
|
||||||
return YES; // Begins with slash ... absolute on unix.
|
* or on windows and not in unix mode.
|
||||||
}
|
*/
|
||||||
#endif
|
if (c == '/')
|
||||||
root = rootOf(self, l);
|
|
||||||
if (root > 0 && pathSepMember([self characterAtIndex: root-1]))
|
|
||||||
{
|
{
|
||||||
#if defined(__MINGW__)
|
#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
|
#endif
|
||||||
if (root == 1 && c == '\\')
|
}
|
||||||
{
|
|
||||||
return NO; // Single backslash is not absolute
|
/*
|
||||||
}
|
* Any root over two characters long must be a drive specification with a
|
||||||
return YES; // Root ends with separator ... absolute.
|
* 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;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue