mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +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
ec5fe0477c
commit
44a6542243
2 changed files with 45 additions and 25 deletions
|
@ -1884,39 +1884,28 @@ static NSStringEncoding defaultEncoding;
|
||||||
#endif
|
#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*) fileSystemRepresentationWithPath: (NSString*)path
|
||||||
{
|
{
|
||||||
const _CHAR *c_path = 0;
|
return [path cStringUsingEncoding: defaultEncoding];
|
||||||
|
|
||||||
if (path != nil)
|
|
||||||
{
|
|
||||||
#ifdef __MINGW32__
|
|
||||||
c_path = (_CCP)[path cStringUsingEncoding: NSUnicodeStringEncoding];
|
|
||||||
#else
|
|
||||||
c_path = (_CCP)[path cStringUsingEncoding: defaultEncoding];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return (const char*)c_path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
- (NSString*) stringWithFileSystemRepresentation: (const char*)string
|
||||||
length: (unsigned int)len
|
length: (unsigned int)len
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
|
||||||
return [NSString stringWithCharacters: (const unichar*)string length: len/2];
|
|
||||||
#else
|
|
||||||
return AUTORELEASE([[NSString allocWithZone: NSDefaultMallocZone()]
|
return AUTORELEASE([[NSString allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithBytes: string length: len encoding: defaultEncoding]);
|
initWithBytes: string length: len encoding: defaultEncoding]);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@end /* NSFileManager */
|
@end /* NSFileManager */
|
||||||
|
|
||||||
|
|
|
@ -3469,13 +3469,43 @@ handle_printf_atsign (FILE *stream,
|
||||||
|
|
||||||
static NSFileManager *fm = nil;
|
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
|
- (const char*) fileSystemRepresentation
|
||||||
{
|
{
|
||||||
if (fm == nil)
|
if (fm == nil)
|
||||||
{
|
{
|
||||||
fm = RETAIN([NSFileManager defaultManager]);
|
fm = RETAIN([NSFileManager defaultManager]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [fm fileSystemRepresentationWithPath: self];
|
return [fm fileSystemRepresentationWithPath: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3488,6 +3518,7 @@ static NSFileManager *fm = nil;
|
||||||
strcpy(buffer, ptr);
|
strcpy(buffer, ptr);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
- (NSString*) lastPathComponent
|
- (NSString*) lastPathComponent
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue