Windows path handling fixups by Roland Schwingel

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17802 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-10-08 14:27:11 +00:00
parent bc1256b6dd
commit c019ce0f9e
4 changed files with 24 additions and 4 deletions

View file

@ -4,6 +4,10 @@
worked as expected and moved getpwnam() call to where it works. worked as expected and moved getpwnam() call to where it works.
* Source/Additions/GSMime.m: ([GSMimeDocument-rawMimeData:]) bugfix * Source/Additions/GSMime.m: ([GSMimeDocument-rawMimeData:]) bugfix
to remove mjime version header from inner documents. to remove mjime version header from inner documents.
* Source/NSBundle.m: Fixup for windows.
* Source/NSFileManager.m: Fixup for windows.
* Source/NSString.m: Fixup for windows.
Windows fixups adapted from patch by <Roland.Schwingel@onevision.de>
2003-10-07 Richard Frith-Macdonald <rfm@gnu.org> 2003-10-07 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -603,8 +603,13 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
#endif #endif
if (_executable_path == nil || [_executable_path length] == 0) if (_executable_path == nil || [_executable_path length] == 0)
{ {
const char *tmp;
_executable_path = _executable_path =
[[[NSProcessInfo processInfo] arguments] objectAtIndex: 0]; [[[NSProcessInfo processInfo] arguments] objectAtIndex: 0];
tmp = [_executable_path UTF8String];
_executable_path = [[NSFileManager defaultManager]
stringWithFileSystemRepresentation: tmp length: strlen(tmp)];
_executable_path = _executable_path =
[self _absolutePathOfExecutable: _executable_path]; [self _absolutePathOfExecutable: _executable_path];
NSAssert(_executable_path, NSInternalInconsistencyException); NSAssert(_executable_path, NSInternalInconsistencyException);

View file

@ -1823,7 +1823,8 @@ static NSFileManager* defaultManager = nil;
{ {
return @""; return @"";
} }
if (len >= 2 && ptr[1] == '/' && ptr[0] == '/') if (len >= 2
&& ((ptr[1] == '/' && ptr[0] == '/') || (ptr[1] == '\\' && ptr[0] == '\\'))
{ {
/* /*
* Convert '//<servername>/' to '~@<servername>/' sequences. * Convert '//<servername>/' to '~@<servername>/' sequences.

View file

@ -3099,8 +3099,9 @@ handle_printf_atsign (FILE *stream,
{ {
NSString *homedir; NSString *homedir;
NSRange first_slash_range; NSRange first_slash_range;
unsigned length;
if ([self length] == 0) if ((length = [self length]) == 0)
{ {
return self; return self;
} }
@ -3109,6 +3110,15 @@ handle_printf_atsign (FILE *stream,
return self; return self;
} }
/*
* Anything beginning '~@' is assumed to be a windows path specification
* which can't be expanded.
*/
if (length > 1 && [self characterAtIndex: 1] == 0x0040)
{
return self;
}
first_slash_range = [self rangeOfCharacterFromSet: pathSeps()]; first_slash_range = [self rangeOfCharacterFromSet: pathSeps()];
if (first_slash_range.location != 1) if (first_slash_range.location != 1)
@ -3137,7 +3147,7 @@ handle_printf_atsign (FILE *stream,
} }
if (homedir != nil) if (homedir != nil)
{ {
return [NSStringClass stringWithFormat: @"%@%@", homedir, return [homedir stringByAppendingPathComponent:
[self substringFromIndex: first_slash_range.location]]; [self substringFromIndex: first_slash_range.location]];
} }
else else
@ -3163,7 +3173,7 @@ handle_printf_atsign (FILE *stream,
{ {
return @"~"; return @"~";
} }
return [NSStringClass stringWithFormat: @"~/%@", return [@"~" stringByAppendingPathComponent:
[self substringFromIndex: [homedir length] + 1]]; [self substringFromIndex: [homedir length] + 1]];
} }