Fix for mingw

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10413 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2001-07-11 09:30:06 +00:00
parent 0da2a314a7
commit 749bad38ce
2 changed files with 31 additions and 8 deletions

View file

@ -1,7 +1,13 @@
2001-07-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: ([fileSystemRepresentationWithPath:])
MINGW fix contributed by Michael Scheibler
2001-07-10 Richard Frith-Macdonald <rfm@gnu.org> 2001-07-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: Update date/time designations to arrays * Source/NSUserDefaults.m: Update date/time designations to arrays
* Source/NSDate.m: Update to use date/time designation arrays. * Source/NSDate.m: Update to use date/time designation arrays.
2001-07-09 Richard Frith-Macdonald <rfm@gnu.org> 2001-07-09 Richard Frith-Macdonald <rfm@gnu.org>
* Source/objc-load.m: Remove bogus include of objc-load.h * Source/objc-load.m: Remove bogus include of objc-load.h

View file

@ -1280,15 +1280,32 @@ static NSFileManager* defaultManager = nil;
- (const char*) fileSystemRepresentationWithPath: (NSString*)path - (const char*) fileSystemRepresentationWithPath: (NSString*)path
{ {
#ifdef __MINGW__ #ifdef __MINGW__
/* If path is in Unix format, transmorgrify it so Windows functions /*
can handle it */ * If path is in Unix format, transmorgrify it so Windows functions
NSString *newpath = path; * can handle it
const char *c_path = [path cString]; */
if (c_path[0] == '/' && c_path[1] == '/' && isalpha(c_path[2])) NSString *newpath = path;
const char *c_path = [path cString];
int len = [path length];
if (c_path == 0)
{ {
/* Cygwin "//c/" type absolute path */ return 0;
newpath = [NSString stringWithFormat: @"%c:%s", c_path[2], &c_path[3]]; }
newpath = [newpath stringByReplacingString: @"/" withString: @"\\"]; if (len >= 3 && c_path[0] == '/' && c_path[1] == '/' && isalpha(c_path[2]))
{
if (len == 3 || c_path[3] == '/')
{
/* Cygwin "//c/" type absolute path */
newpath = [NSString stringWithFormat: @"%c:%s", c_path[2],
&c_path[3]];
newpath = [newpath stringByReplacingString: @"/" withString: @"\\"];
}
else
{
/* Windows absolute UNC path "//name/" */
newpath = [newpath stringByReplacingString: @"/" withString: @"\\"];
}
} }
else if (isalpha(c_path[0]) && c_path[1] == ':') else if (isalpha(c_path[0]) && c_path[1] == ':')
{ {