mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21954 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ffb1c7466d
commit
4ef387ccd5
2 changed files with 45 additions and 25 deletions
|
@ -1884,39 +1884,28 @@ static NSStringEncoding defaultEncoding;
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(__MINGW__)
|
||||
- (const unichar*) fileSystemRepresentationWithPath: (NSString*)path
|
||||
{
|
||||
return (const unichar*)[path cStringUsingEncoding: NSUnicodeStringEncoding];
|
||||
}
|
||||
- (NSString*) stringWithFileSystemRepresentation: (const unichar*)string
|
||||
length: (unsigned int)len
|
||||
{
|
||||
return [NSString stringWithCharacters: (const unichar*)string length: len/2];
|
||||
}
|
||||
#else
|
||||
- (const char*) fileSystemRepresentationWithPath: (NSString*)path
|
||||
{
|
||||
const _CHAR *c_path = 0;
|
||||
|
||||
if (path != nil)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
c_path = (_CCP)[path cStringUsingEncoding: NSUnicodeStringEncoding];
|
||||
#else
|
||||
c_path = (_CCP)[path cStringUsingEncoding: defaultEncoding];
|
||||
#endif
|
||||
}
|
||||
|
||||
return (const char*)c_path;
|
||||
return [path cStringUsingEncoding: defaultEncoding];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method converts from a local filesystem specific name
|
||||
* to an NSString object. Use it to convert a filename returned by
|
||||
* a systemcall into a value for internal use.<br />
|
||||
* The value of len is the number of bytes of data pointed to by string.<br />
|
||||
* On windows, the filesystem representation is utf-16.
|
||||
*/
|
||||
- (NSString*) stringWithFileSystemRepresentation: (const char*)string
|
||||
length: (unsigned int)len
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
return [NSString stringWithCharacters: (const unichar*)string length: len/2];
|
||||
#else
|
||||
return AUTORELEASE([[NSString allocWithZone: NSDefaultMallocZone()]
|
||||
initWithBytes: string length: len encoding: defaultEncoding]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@end /* NSFileManager */
|
||||
|
||||
|
|
|
@ -3469,13 +3469,43 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
static NSFileManager *fm = nil;
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
- (const unichar*) fileSystemRepresentation
|
||||
{
|
||||
if (fm == nil)
|
||||
{
|
||||
fm = RETAIN([NSFileManager defaultManager]);
|
||||
}
|
||||
return [fm fileSystemRepresentationWithPath: self];
|
||||
}
|
||||
|
||||
- (BOOL) getFileSystemRepresentation: (unichar*)buffer
|
||||
maxLength: (unsigned int)size
|
||||
{
|
||||
const unichar *ptr = [self fileSystemRepresentation];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = ptr[i];
|
||||
if (ptr[i] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == size && ptr[i] != 0)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
#else
|
||||
- (const char*) fileSystemRepresentation
|
||||
{
|
||||
if (fm == nil)
|
||||
{
|
||||
fm = RETAIN([NSFileManager defaultManager]);
|
||||
}
|
||||
|
||||
return [fm fileSystemRepresentationWithPath: self];
|
||||
}
|
||||
|
||||
|
@ -3488,6 +3518,7 @@ static NSFileManager *fm = nil;
|
|||
strcpy(buffer, ptr);
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (NSString*) lastPathComponent
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue