mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fixes for tilde handling on windows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39466 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b1bc2f8af7
commit
9fbe3bafef
3 changed files with 13 additions and 3 deletions
|
@ -1719,7 +1719,7 @@ NSUserName(void)
|
|||
NSString *
|
||||
NSHomeDirectory(void)
|
||||
{
|
||||
return NSHomeDirectoryForUser (NSUserName ());
|
||||
return NSHomeDirectoryForUser(NSUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1810,6 +1810,10 @@ NSHomeDirectoryForUser(NSString *loginName)
|
|||
fprintf(stderr, "NSHomeDirectoryForUser(%s) failed.\n",
|
||||
[loginName UTF8String]);
|
||||
}
|
||||
if (nil != s)
|
||||
{
|
||||
s = [s stringByStandardizingPath];
|
||||
}
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
|
@ -2094,7 +2098,7 @@ NSOpenStepRootDirectory(void)
|
|||
#if defined(__CYGWIN__)
|
||||
root = @"/cygdrive/c/";
|
||||
#elif defined(__MINGW__)
|
||||
root = @"C:\\";
|
||||
root = @"C:/";
|
||||
#else
|
||||
root = @"/";
|
||||
#endif
|
||||
|
|
|
@ -4729,12 +4729,13 @@ static NSFileManager *fm = nil;
|
|||
|
||||
- (NSString*) stringByAbbreviatingWithTildeInPath
|
||||
{
|
||||
NSString *homedir = NSHomeDirectory ();
|
||||
NSString *homedir;
|
||||
|
||||
if (YES == [self hasPrefix: @"~"])
|
||||
{
|
||||
return IMMUTABLE(self);
|
||||
}
|
||||
homedir = NSHomeDirectory();
|
||||
if (NO == [self hasPrefix: homedir])
|
||||
{
|
||||
/* OSX compatibility ... we clean up the path to try to get a
|
||||
|
|
|
@ -32,9 +32,14 @@ int main()
|
|||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents/./..",
|
||||
"dot directory reference retained");
|
||||
|
||||
#ifndef _WIN32
|
||||
/* This test can't work on windows, because the ome directory of a
|
||||
* user doesn't start with a slash... don't run it on _WIN32
|
||||
*/
|
||||
tmp = [NSString stringWithFormat: @"////%@//Documents///", home];
|
||||
PASS_EQUAL([tmp stringByAbbreviatingWithTildeInPath], @"~/Documents",
|
||||
"multiple slashes removed");
|
||||
#endif
|
||||
|
||||
PASS_EQUAL([@"//////Documents///" stringByAbbreviatingWithTildeInPath],
|
||||
@"/Documents",
|
||||
|
|
Loading…
Reference in a new issue