* Add support for systems that support unichar file paths (e.g.

Windows).
* Headers/Foundation/NSFileManager.h (-localFromOpenStepPath:,
_openStepPathFromLocal:): New methods.
(NSDirectoryEnumerator): Updated ivars.
* Source/NSFileManager.m: Idem.
(-changeCurrentDirectoryPath, changeFileAttributes:,
currentDirectoryPath, etc): Update for Windows unichar paths.
* Headers/Foundation/NSString.h: (-unicharString,
-localFromOpenStepPath:, _openStepPathFromLocal:): New methods.
* Source/NSString.m: Idem.
* Source/GSFileHandle.m (-initForReadingAtPath:,
-initForWritingAtPath, -initForUpdatingAtPath:): Update for Windows
unichar paths.
* Source/NSData.m (readContentsOfFile, -writeToFile:,
initWithContentsOfMappedFile:): Idem.
* Source/NSTask.m (NSConcreteWindowsTask): Update for Windows
unichar paths.
(Patch from Roland Schwingle <roland.schwingel@onevision.de>)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20502 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2004-12-29 04:21:37 +00:00
parent 257787f99e
commit 142f0b1784
9 changed files with 1171 additions and 801 deletions

View file

@ -1,3 +1,25 @@
2004-12-26 Adam Fedor <fedor@gnu.org>
* Add support for systems that support unichar file paths (e.g.
Windows).
* Headers/Foundation/NSFileManager.h (-localFromOpenStepPath:,
_openStepPathFromLocal:): New methods.
(NSDirectoryEnumerator): Updated ivars.
* Source/NSFileManager.m: Idem.
(-changeCurrentDirectoryPath, changeFileAttributes:,
currentDirectoryPath, etc): Update for Windows unichar paths.
* Headers/Foundation/NSString.h: (-unicharString,
-localFromOpenStepPath:, _openStepPathFromLocal:): New methods.
* Source/NSString.m: Idem.
* Source/GSFileHandle.m (-initForReadingAtPath:,
-initForWritingAtPath, -initForUpdatingAtPath:): Update for Windows
unichar paths.
* Source/NSData.m (readContentsOfFile, -writeToFile:,
initWithContentsOfMappedFile:): Idem.
* Source/NSTask.m (NSConcreteWindowsTask): Update for Windows
unichar paths.
(Patch from Roland Schwingle <roland.schwingel@onevision.de>)
2004-12-28 Richard Frith-Macdonald <rfm@gnu.org> 2004-12-28 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdnc.m: Change name of dummy class to avoid Darwin linker * Tools/gdnc.m: Change name of dummy class to avoid Darwin linker

View file

@ -56,7 +56,7 @@
<td width="50%"> <td width="50%">
The GUI portion of GNUstep. The GUI portion of GNUstep.
<ul> <ul>
<li>User Defaults (<a href="documentation/User/Gui/DefaultsSummary.html">GUI</a>) (<a href="Developer/Back/General/DefaultsSummary.html">Back</a>)</li> <li>User Defaults (<a href="documentation/User/Gui/DefaultsSummary.html">GUI</a>) (<a href="documentation/Developer/Back/General/DefaultsSummary.html">Back</a>)</li>
<li><a href="documentation/User/Gui/KeyboardSetup.html">User Keyboard Setup</a></li> <li><a href="documentation/User/Gui/KeyboardSetup.html">User Keyboard Setup</a></li>
<li><a href="documentation/User/Gui/LanguageSetup.html">Setup for East Asian Languages</a></li> <li><a href="documentation/User/Gui/LanguageSetup.html">Setup for East Asian Languages</a></li>
</ul> </ul>
@ -139,29 +139,33 @@
</p> </p>
<br/><br/> <br/><br/>
</div> </div></div>
</div> </div>
<div class="sidebar"> <div class="sidebar">
<b>General</b><br /> <b>General</b><br />
<a href="../">Home page</a><br /> <a href="../">Home page</a><br />
<a href="../information/aboutGNUstep.html">Introduction</a><br /> <a href="../information/aboutGNUstep.html">Introduction</a><br />
<a href="../information/mission.html">Mission</a><br /> <a href="../experience/documentation.html">Getting Started</a><br />
<a href="../information/machines_toc.html">Platforms</a><br />
<a href="../resources/sources.html">Download</a><br /> <a href="../resources/sources.html">Download</a><br />
<a href="../experience/apps.html">Applications</a><br /> <a href="../experience/apps.html">Applications</a><br />
<a href="../resources/documentation/User/GNUstep/userfaq_toc.html">User FAQ</a><br /> <a href="../resources/documentation/User/GNUstep/userfaq_toc.html">User FAQ</a><br />
<a href="../experience/documentation.html">Getting Started</a><br /> <a href="../information/machines_toc.html">Supported Platforms</a><br />
<a href="../information/donate.html">Donations</a><br /> <a href="../information/donate.html">Donations</a><br />
<br /> <br />
<a href="../developers/bugs.html">Report Bugs</a><br />
<br />
<b>Developers</b><br /> <b>Developers</b><br />
<a href="../resources/docs-web.html">Documentation</a><br /> <a href="../resources/docs-web.html">Documentation</a><br />
<a href="../experience/DeveloperTools.html">Developer Tools</a><br />
<a href="http://wiki.gnustep.org/">Wiki Docs</a><br /> <a href="http://wiki.gnustep.org/">Wiki Docs</a><br />
<a href="../resources/documentation/User/GNUstep/faq_toc.html">Developer FAQ</a><br /> <a href="../resources/documentation/User/GNUstep/faq_toc.html">Developer FAQ</a><br />
<a href="../developers/map.html">Libraries</a><br /> <a href="../developers/map.html">Libraries</a><br />
<a href="../developers/whoiswho.html">Who's Who</a>?<br /> <a href="../developers/whoiswho.html">Who's Who</a>?<br />
<a href="../information/mission.html">Mission</a><br />
<br /> <br />
<b>External</b><br /> <b>External</b><br />
<a href="http://savannah.gnu.org/projects/gnustep/">Project Page</a><br /> <a href="http://savannah.gnu.org/projects/gnustep/">Project Page</a><br />

View file

@ -76,6 +76,10 @@
- (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory; - (BOOL) fileExistsAtPath: (NSString*)path isDirectory: (BOOL*)isDirectory;
- (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path; - (NSDictionary*) fileSystemAttributesAtPath: (NSString*)path;
- (const char*) fileSystemRepresentationWithPath: (NSString*)path; - (const char*) fileSystemRepresentationWithPath: (NSString*)path;
#ifndef NO_GNUSTEP
- (NSString*) localFromOpenStepPath:(NSString*)path;
- (NSString*) openStepPathFromLocal:(NSString*)localPath;
#endif
- (BOOL) isExecutableFileAtPath: (NSString*)path; - (BOOL) isExecutableFileAtPath: (NSString*)path;
- (BOOL) isDeletableFileAtPath: (NSString*)path; - (BOOL) isDeletableFileAtPath: (NSString*)path;
- (BOOL) isReadableFileAtPath: (NSString*)path; - (BOOL) isReadableFileAtPath: (NSString*)path;
@ -155,9 +159,9 @@
@interface NSDirectoryEnumerator : NSEnumerator @interface NSDirectoryEnumerator : NSEnumerator
{ {
void *_stack; /* GSIArray */ void *_stack; /* GSIArray */
char *_top_path; NSString *_topPath;
char *_current_file_path; NSString *_currentFilePath;
NSString *(*_stringWithFileSysImp)(id, SEL, char *, unsigned); NSString *(*_openStepPathFromLocalImp)(id, SEL, id);
struct struct
{ {
BOOL isRecursive: 1; BOOL isRecursive: 1;

View file

@ -276,6 +276,9 @@ enum {
- (NSString*) lowercaseString; - (NSString*) lowercaseString;
- (NSString*) uppercaseString; - (NSString*) uppercaseString;
#ifndef NO_GNUSTEP
- (const unichar*) unicharString;
#endif
// Getting C Strings // Getting C Strings
- (const char*) cString; - (const char*) cString;
- (unsigned int) cStringLength; - (unsigned int) cStringLength;
@ -306,6 +309,10 @@ enum {
caseSensitive: (BOOL)flag caseSensitive: (BOOL)flag
matchesIntoArray: (NSArray**)outputArray matchesIntoArray: (NSArray**)outputArray
filterTypes: (NSArray*)filterTypes; filterTypes: (NSArray*)filterTypes;
#ifndef NO_GNUSTEP
- (NSString*) localFromOpenStepPath;
- (NSString*) openStepPathFromLocal;
#endif
- (const char*) fileSystemRepresentation; - (const char*) fileSystemRepresentation;
- (BOOL) getFileSystemRepresentation: (char*)buffer - (BOOL) getFileSystemRepresentation: (char*)buffer
maxLength: (unsigned int)size; maxLength: (unsigned int)size;

View file

@ -992,7 +992,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (id) initForReadingAtPath: (NSString*)path - (id) initForReadingAtPath: (NSString*)path
{ {
#if defined(__MINGW__)
int d = _wopen([[path localFromOpenStepPath] unicharString], O_RDONLY|O_BINARY);
#else
int d = open([path fileSystemRepresentation], O_RDONLY|O_BINARY); int d = open([path fileSystemRepresentation], O_RDONLY|O_BINARY);
#endif
if (d < 0) if (d < 0)
{ {
@ -1014,7 +1018,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (id) initForWritingAtPath: (NSString*)path - (id) initForWritingAtPath: (NSString*)path
{ {
#if defined(__MINGW__)
int d = _wopen([[path localFromOpenStepPath] unicharString], O_WRONLY|O_BINARY);
#else
int d = open([path fileSystemRepresentation], O_WRONLY|O_BINARY); int d = open([path fileSystemRepresentation], O_WRONLY|O_BINARY);
#endif
if (d < 0) if (d < 0)
{ {
@ -1036,7 +1044,11 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
- (id) initForUpdatingAtPath: (NSString*)path - (id) initForUpdatingAtPath: (NSString*)path
{ {
#if defined(__MINGW__)
int d = _wopen([[path localFromOpenStepPath] unicharString], O_RDWR|O_BINARY);
#else
int d = open([path fileSystemRepresentation], O_RDWR|O_BINARY); int d = open([path fileSystemRepresentation], O_RDWR|O_BINARY);
#endif
if (d < 0) if (d < 0)
{ {

View file

@ -64,6 +64,10 @@
* *
*/ */
#if defined(__MINGW32__)
#define UNICODE
#define _UNICODE
#endif
#include "config.h" #include "config.h"
#include "GNUstepBase/GSObjCRuntime.h" #include "GNUstepBase/GSObjCRuntime.h"
#include "Foundation/NSObjCRuntime.h" #include "Foundation/NSObjCRuntime.h"
@ -128,28 +132,42 @@ static IMP appendImp;
static BOOL static BOOL
readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone) readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
{ {
char thePath[BUFSIZ*2]; NSString *localPath = [path localFromOpenStepPath];
#if defined(__MINGW__)
const unichar *thePath = NULL;
#else
const char *thePath = NULL;
#endif
FILE *theFile = 0; FILE *theFile = 0;
void *tmp = 0; void *tmp = 0;
int c; int c;
long fileLength; long fileLength;
#if GS_WITH_GC == 1 #if GS_WITH_GC == 1
zone = GSAtomicMallocZone(); // Use non-GC memory inside NSData zone = GSAtomicMallocZone(); // Use non-GC memory inside NSData
#endif #endif
if ([path getFileSystemRepresentation: thePath #if defined(__MINGW__)
maxLength: sizeof(thePath)-1] == NO) thePath = [localPath unicharString];
#else
thePath = [localPath fileSystemRepresentation];
#endif
if (thePath == NULL)
{ {
NSWarnFLog(@"Open (%s) attempt failed - bad path", thePath); NSWarnFLog(@"Open (%@) attempt failed - bad path",localPath);
return NO; return NO;
} }
#if defined(__MINGW__)
theFile = _wfopen(thePath, L"rb");
#else
theFile = fopen(thePath, "rb"); theFile = fopen(thePath, "rb");
#endif
if (theFile == NULL) /* We failed to open the file. */ if (theFile == NULL) /* We failed to open the file. */
{ {
NSWarnFLog(@"Open (%s) attempt failed - %s", thePath, NSWarnFLog(@"Open (%@) attempt failed - %s",localPath,
GSLastErrorStr(errno)); GSLastErrorStr(errno));
goto failure; goto failure;
} }
@ -160,7 +178,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
c = fseek(theFile, 0L, SEEK_END); c = fseek(theFile, 0L, SEEK_END);
if (c != 0) if (c != 0)
{ {
NSWarnFLog(@"Seek to end of file (%s) failed - %s", thePath, NSWarnFLog(@"Seek to end of file (%@) failed - %s",localPath,
GSLastErrorStr(errno)); GSLastErrorStr(errno));
goto failure; goto failure;
} }
@ -172,7 +190,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
fileLength = ftell(theFile); fileLength = ftell(theFile);
if (fileLength == -1) if (fileLength == -1)
{ {
NSWarnFLog(@"Ftell on %s failed - %s", thePath, GSLastErrorStr(errno)); NSWarnFLog(@"Ftell on %@ failed - %s",localPath,
GSLastErrorStr(errno));
goto failure; goto failure;
} }
@ -183,8 +202,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
c = fseek(theFile, 0L, SEEK_SET); c = fseek(theFile, 0L, SEEK_SET);
if (c != 0) if (c != 0)
{ {
NSWarnFLog(@"Fseek to start of file (%s) failed - %s", NSWarnFLog(@"Fseek to start of file (%@) failed - %s",localPath,
thePath, GSLastErrorStr(errno)); GSLastErrorStr(errno));
goto failure; goto failure;
} }
@ -209,8 +228,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
} }
if (tmp == 0) if (tmp == 0)
{ {
NSLog(@"Malloc failed for file (%s) of length %d - %s", NSLog(@"Malloc failed for file (%@) of length %d - %s",localPath,
thePath, fileLength + c, GSLastErrorStr(errno)); fileLength + c, GSLastErrorStr(errno));
goto failure; goto failure;
} }
memcpy(tmp + fileLength, buf, c); memcpy(tmp + fileLength, buf, c);
@ -222,16 +241,16 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
tmp = NSZoneMalloc(zone, fileLength); tmp = NSZoneMalloc(zone, fileLength);
if (tmp == 0) if (tmp == 0)
{ {
NSLog(@"Malloc failed for file (%s) of length %d - %s", NSLog(@"Malloc failed for file (%@) of length %d - %s",localPath,
thePath, fileLength, GSLastErrorStr(errno)); fileLength, GSLastErrorStr(errno));
goto failure; goto failure;
} }
c = fread(tmp, 1, fileLength, theFile); c = fread(tmp, 1, fileLength, theFile);
if (c != (int)fileLength) if (c != (int)fileLength)
{ {
NSWarnFLog(@"read of file (%s) contents failed - %s", NSWarnFLog(@"read of file (%@) contents failed - %s",localPath,
thePath, GSLastErrorStr(errno)); GSLastErrorStr(errno));
goto failure; goto failure;
} }
} }
@ -256,8 +275,6 @@ failure:
return NO; return NO;
} }
/* /*
* NB, The start of the NSMutableDataMalloc instance variables must be * NB, The start of the NSMutableDataMalloc instance variables must be
* identical to that of NSDataMalloc in order to inherit its methods. * identical to that of NSDataMalloc in order to inherit its methods.
@ -804,15 +821,37 @@ static unsigned gsu32Align;
*/ */
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile - (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile
{ {
NSString *localPath = [path localFromOpenStepPath];
#if defined(__MINGW__)
unichar wthePath[[localPath length]+100];
unichar wtheRealPath[[localPath length]+100];
#else
char thePath[BUFSIZ*2+8]; char thePath[BUFSIZ*2+8];
char theRealPath[BUFSIZ*2]; char theRealPath[BUFSIZ*2];
#endif
int c; int c;
FILE *theFile; FILE *theFile;
BOOL error_BadPath = YES;
if ([path getFileSystemRepresentation: theRealPath #if defined(__MINGW__)
maxLength: sizeof(theRealPath)-1] == NO) [localPath getCharacters:wtheRealPath];
wtheRealPath[[localPath length]] = L'\0';
error_BadPath = ([localPath length] <= 0);
#else
if ([localPath canBeConvertedToEncoding: [NSString defaultCStringEncoding]])
{ {
NSWarnMLog(@"Open (%s) attempt failed - bad path", theRealPath); const char *local_c_path = [localPath cString];
if (local_c_path != NULL && strlen(local_c_path) < (BUFSIZ*2))
{
strcpy(theRealPath,local_c_path);
error_BadPath = NO;
}
}
#endif
if (error_BadPath)
{
NSWarnMLog(@"Open (%@) attempt failed - bad path",path);
return NO; return NO;
} }
@ -849,6 +888,17 @@ static unsigned gsu32Align;
/* Use the path name of the destination file as a prefix for the /* Use the path name of the destination file as a prefix for the
* mktemp() call so that we can be sure that both files are on * mktemp() call so that we can be sure that both files are on
* the same filesystem and the subsequent rename() will work. */ * the same filesystem and the subsequent rename() will work. */
#if defined(__MINGW__)
wcscpy(wthePath, wtheRealPath);
wcscat(wthePath, L"XXXXXX");
if (_wmktemp(wthePath) == 0)
{
NSWarnMLog(@"mktemp (%@) failed - %s",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
GSLastErrorStr(errno));
goto failure;
}
#else
strcpy(thePath, theRealPath); strcpy(thePath, theRealPath);
strcat(thePath, "XXXXXX"); strcat(thePath, "XXXXXX");
if (mktemp(thePath) == 0) if (mktemp(thePath) == 0)
@ -857,20 +907,35 @@ static unsigned gsu32Align;
GSLastErrorStr(errno)); GSLastErrorStr(errno));
goto failure; goto failure;
} }
#endif
} }
else else
{ {
#if defined(__MINGW__)
wcscpy(wthePath,wtheRealPath);
#else
strcpy(thePath, theRealPath); strcpy(thePath, theRealPath);
#endif
} }
/* Open the file (whether temp or real) for writing. */ /* Open the file (whether temp or real) for writing. */
#if defined(__MINGW__)
theFile = _wfopen(wthePath, L"wb");
#else
theFile = fopen(thePath, "wb"); theFile = fopen(thePath, "wb");
#endif
#endif #endif
if (theFile == NULL) /* Something went wrong; we weren't if (theFile == NULL) /* Something went wrong; we weren't
* even able to open the file. */ * even able to open the file. */
{ {
#if defined(__MINGW__)
NSWarnMLog(@"Open (%@) failed - %s",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
GSLastErrorStr(errno));
#else
NSWarnMLog(@"Open (%s) failed - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"Open (%s) failed - %s", thePath, GSLastErrorStr(errno));
#endif
goto failure; goto failure;
} }
@ -882,7 +947,13 @@ static unsigned gsu32Align;
if (c < (int)[self length]) /* We failed to write everything for if (c < (int)[self length]) /* We failed to write everything for
* some reason. */ * some reason. */
{ {
#if defined(__MINGW__)
NSWarnMLog(@"Fwrite (%@) failed - %s",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
GSLastErrorStr(errno));
#else
NSWarnMLog(@"Fwrite (%s) failed - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"Fwrite (%s) failed - %s", thePath, GSLastErrorStr(errno));
#endif
goto failure; goto failure;
} }
@ -893,7 +964,13 @@ static unsigned gsu32Align;
* closing the file, but we got here, * closing the file, but we got here,
* so we need to deal with it. */ * so we need to deal with it. */
{ {
#if defined(__MINGW__)
NSWarnMLog(@"Fclose (%@) failed - %s",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
GSLastErrorStr(errno));
#else
NSWarnMLog(@"Fclose (%s) failed - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"Fclose (%s) failed - %s", thePath, GSLastErrorStr(errno));
#endif
goto failure; goto failure;
} }
@ -929,7 +1006,7 @@ static unsigned gsu32Align;
c = -1; c = -1;
} }
#else #else
if (MoveFileEx(thePath, theRealPath, MOVEFILE_REPLACE_EXISTING) != 0) if (MoveFileEx(wthePath, wtheRealPath, MOVEFILE_REPLACE_EXISTING) != 0)
{ {
c = 0; c = 0;
} }
@ -943,8 +1020,15 @@ static unsigned gsu32Align;
#endif #endif
if (c != 0) /* Many things could go wrong, I guess. */ if (c != 0) /* Many things could go wrong, I guess. */
{ {
#if defined(__MINGW__)
NSWarnMLog(@"Rename ('%@' to '%@') failed - %s",
[NSString stringWithCharacters:wthePath length:wcslen(wthePath)],
[NSString stringWithCharacters:wtheRealPath length:wcslen(wtheRealPath)],
GSLastErrorStr(errno));
#else
NSWarnMLog(@"Rename ('%s' to '%s') failed - %s", NSWarnMLog(@"Rename ('%s' to '%s') failed - %s",
thePath, theRealPath, GSLastErrorStr(errno)); thePath, theRealPath, GSLastErrorStr(errno));
#endif
goto failure; goto failure;
} }
@ -990,7 +1074,11 @@ failure:
*/ */
if (useAuxiliaryFile) if (useAuxiliaryFile)
{ {
#if defined(__MINGW__)
_wunlink(wthePath);
#else
unlink(thePath); unlink(thePath);
#endif
} }
return NO; return NO;
} }
@ -2768,19 +2856,31 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (id) initWithContentsOfMappedFile: (NSString*)path - (id) initWithContentsOfMappedFile: (NSString*)path
{ {
int fd; int fd;
char thePath[BUFSIZ*2]; NSString *localPath = [path localFromOpenStepPath];
if ([path getFileSystemRepresentation: thePath #if defined(__MINGW__)
maxLength: sizeof(thePath)-1] == NO) const unichar *thePath = [localPath unicharString];
#else
const char *thePath;
thePath = [localPath fileSystemRepresentation];
#endif
if (thePath == NULL)
{ {
NSWarnMLog(@"Open (%s) attempt failed - bad path", thePath); NSWarnMLog(@"Open (%@) attempt failed - bad path",localPath);
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
#if defined(__MINGW__)
fd = _wopen(thePath, _O_RDONLY);
#else
fd = open(thePath, O_RDONLY); fd = open(thePath, O_RDONLY);
#endif
if (fd < 0) if (fd < 0)
{ {
NSWarnMLog(@"unable to open %s - %s", thePath, GSLastErrorStr(errno)); NSWarnMLog(@"unable to open %@ - %s",localPath,GSLastErrorStr(errno));
RELEASE(self); RELEASE(self);
return nil; return nil;
} }
@ -2788,8 +2888,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
length = lseek(fd, 0, SEEK_END); length = lseek(fd, 0, SEEK_END);
if (length < 0) if (length < 0)
{ {
NSWarnMLog(@"unable to seek to eof %s - %s", NSWarnMLog(@"unable to seek to eof %@ - %s",localPath,
thePath, GSLastErrorStr(errno)); GSLastErrorStr(errno));
close(fd); close(fd);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -2797,8 +2897,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
/* Position at start of file. */ /* Position at start of file. */
if (lseek(fd, 0, SEEK_SET) != 0) if (lseek(fd, 0, SEEK_SET) != 0)
{ {
NSWarnMLog(@"unable to seek to sof %s - %s", NSWarnMLog(@"unable to seek to sof %@ - %s", localPath,
thePath, GSLastErrorStr(errno)); GSLastErrorStr(errno));
close(fd); close(fd);
RELEASE(self); RELEASE(self);
return nil; return nil;
@ -2806,8 +2906,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0); bytes = mmap(0, length, PROT_READ, MAP_SHARED, fd, 0);
if (bytes == MAP_FAILED) if (bytes == MAP_FAILED)
{ {
NSWarnMLog(@"mapping failed for %s - %s", NSWarnMLog(@"mapping failed for %s - %s",localPath, GSLastErrorStr(errno));
thePath, GSLastErrorStr(errno));
close(fd); close(fd);
RELEASE(self); RELEASE(self);
self = [dataMalloc allocWithZone: NSDefaultMallocZone()]; self = [dataMalloc allocWithZone: NSDefaultMallocZone()];

File diff suppressed because it is too large Load diff

View file

@ -2608,6 +2608,31 @@ handle_printf_atsign (FILE *stream,
// Getting C Strings // Getting C Strings
/**
* Returns a pointer to a null terminated string of 16-bit unichar
* The memory pointed to is not owned by the caller, so the
* caller must copy its contents to keep it. Raises an
*/
- (const unichar*) unicharString
{
NSData *returnData = nil;
int len = [self length];
unichar buf[64];
unichar *uniStr = (len < 64) ? buf :
NSZoneMalloc(NSDefaultMallocZone(), (len+1) * sizeof(unichar));
if (uniStr != NULL)
{
[self getCharacters:uniStr];
uniStr[len] = L'\0';
returnData = [NSData dataWithBytes:uniStr length:(len+1)*sizeof(unichar)];
if (uniStr != buf)
NSZoneFree(NSDefaultMallocZone(), uniStr);
return ((const unichar*)[returnData bytes]);
}
return(NULL);
}
/** /**
* Returns a pointer to a null terminated string of 8-bit characters in the * Returns a pointer to a null terminated string of 8-bit characters in the
* default encoding. The memory pointed to is not owned by the caller, so the * default encoding. The memory pointed to is not owned by the caller, so the
@ -3195,6 +3220,39 @@ handle_printf_atsign (FILE *stream,
return [fm fileSystemRepresentationWithPath: self]; return [fm fileSystemRepresentationWithPath: self];
} }
/**
* Converts this string, which is assumed to be a path in Unix notation ('/'
* is file separator, '.' is extension separator) to a string path expressed
* in the convention for the host operating system.
*/
- (NSString*) localFromOpenStepPath
{
static NSFileManager *fm = nil;
if (fm == nil)
{
fm = RETAIN([NSFileManager defaultManager]);
}
return [fm localFromOpenStepPath: self];
}
/**
* Converts this string, which is assumed to be a path in the convention
* for the host operating system to a string path expressed
* in Unix notation ('/' is file separator, '.' is extension separator).
*/
- (NSString*) openStepPathFromLocal
{
static NSFileManager *fm = nil;
if (fm == nil)
{
fm = RETAIN([NSFileManager defaultManager]);
}
return [fm openStepPathFromLocal: self];
}
/** /**
* Converts this string, which is assumed to be a path in Unix notation ('/' * Converts this string, which is assumed to be a path in Unix notation ('/'
@ -3212,6 +3270,7 @@ handle_printf_atsign (FILE *stream,
return YES; return YES;
} }
/** /**
* Returns a string containing the last path component of the receiver.<br /> * Returns a string containing the last path component of the receiver.<br />
* The path component is the last non-empty substring delimited by the ends * The path component is the last non-empty substring delimited by the ends

View file

@ -1064,14 +1064,14 @@ quotedFromString(NSString *aString)
- (void) launch - (void) launch
{ {
DWORD tid; DWORD tid;
STARTUPINFO start_info; STARTUPINFOW start_info;
NSString *lpath; NSString *lpath;
NSString *arg; NSString *arg;
NSEnumerator *arg_enum; NSEnumerator *arg_enum;
NSMutableString *args; NSMutableString *args;
char *c_args; wchar_t *w_args;
int result; int result;
const char *executable; const wchar_t *wexecutable;
if (_hasLaunched) if (_hasLaunched)
{ {
@ -1079,10 +1079,10 @@ quotedFromString(NSString *aString)
} }
lpath = [self _fullLaunchPath]; lpath = [self _fullLaunchPath];
executable = [lpath fileSystemRepresentation]; wexecutable = [[lpath localFromOpenStepPath] unicharString];
args = [[NSMutableString alloc] initWithString: args = [[NSMutableString alloc] initWithString:
quotedFromString([NSString stringWithCString: executable])]; quotedFromString([NSString stringWithCharacters:wexecutable length:wcslen(wexecutable)])];
arg_enum = [[self arguments] objectEnumerator]; arg_enum = [[self arguments] objectEnumerator];
while ((arg = [arg_enum nextObject])) while ((arg = [arg_enum nextObject]))
{ {
@ -1090,8 +1090,8 @@ quotedFromString(NSString *aString)
[args appendString: quotedFromString(arg)]; [args appendString: quotedFromString(arg)];
} }
c_args = NSZoneMalloc(NSDefaultMallocZone(), [args cStringLength]+1); w_args = NSZoneMalloc(NSDefaultMallocZone(),sizeof(wchar_t) *([args length]+1));
[args getCString: c_args]; [args getCharacters: (unichar*)w_args];
memset (&start_info, 0, sizeof(start_info)); memset (&start_info, 0, sizeof(start_info));
start_info.cb = sizeof(start_info); start_info.cb = sizeof(start_info);
@ -1100,20 +1100,20 @@ quotedFromString(NSString *aString)
start_info.hStdOutput = [[self standardOutput] nativeHandle]; start_info.hStdOutput = [[self standardOutput] nativeHandle];
start_info.hStdError = [[self standardError] nativeHandle]; start_info.hStdError = [[self standardError] nativeHandle];
result = CreateProcess(executable, result = CreateProcessW(wexecutable,
c_args, w_args,
NULL, /* proc attrs */ NULL, /* proc attrs */
NULL, /* thread attrs */ NULL, /* thread attrs */
1, /* inherit handles */ 1, /* inherit handles */
0, /* creation flags */ 0, /* creation flags */
NULL, /* env block */ NULL, /* env block */
[[self currentDirectoryPath] fileSystemRepresentation], [[[self currentDirectoryPath] localFromOpenStepPath] unicharString],
&start_info, &start_info,
&procInfo); &procInfo);
NSZoneFree(NSDefaultMallocZone(), c_args); NSZoneFree(NSDefaultMallocZone(), w_args);
if (result == 0) if (result == 0)
{ {
NSLog(@"Error launching task: %s", executable); NSLog(@"Error launching task: %@", lpath);
return; return;
} }