diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m
index 035391a39..6f6d054eb 100644
--- a/Source/NSFileManager.m
+++ b/Source/NSFileManager.m
@@ -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.
- * The value of len is the number of bytes of data pointed to by string.
- * 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 */
diff --git a/Source/NSString.m b/Source/NSString.m
index 0bd17e349..76470f7bf 100644
--- a/Source/NSString.m
+++ b/Source/NSString.m
@@ -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
{