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:
Richard Frith-MacDonald 2016-03-05 17:28:06 +00:00
parent b1bc2f8af7
commit 9fbe3bafef
3 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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",