FROM : Michael Vannorsdel
DATE : Thu May 15 13:20:03 2008
This has to do with non-printable characters in pathnames. Each
application can different how they visually represent these
characters. The terminal just replaces them with '?', the Finder
might use a space.
When you have a path from NSFileManager, leave it as is in the
NSString if you're going to pass it to other Foundation file manager
APIs. If you need a C string of the path for C APIs, you can use
NSFileManager's fileSystemRepresentationWithPath: to get a properly
encoded C string. Also displayNameAtPath: can give you the proper
representation for displaying the path to the user but may not work
when passed to file system APIs.
On May 15, 2008, at 4:17 AM, JanakiRam wrote:
> I'm facing an issue with NSFileManger directoryContentsAtPath API.
> This
> seems to be an wried issue. But its very important for me to fix.
> Please
> help me.
>
> My application is trying to enumerate the folders in inside a Mac
> using NSFileManager API. But for some files its failing.
>
> It looks like the file name ( inside bundle ) is interpreted by
> Finder and
> Terminal in a different ways. Can any one please suggest me a way to
> resolve
> this issue.
>
> Thanks in Advance
>
> *Cocoa Code for your reference.*
>
> NSFileManager *defaultManager = [NSFileManager defaultManager];
> NSArray *filePath = [defaultManager directoryContentsAtPath:
> @"/Users/janakiram/Downloads/Folder.tiff"];
> int i , count = [filePath count];
>
> for ( i = 0 ; i < count ; i++ ) {
> NSLog(@" filepath is (%@)",[filePath objectAtIndex:i]);
>
> }
>
> *Output:*
>
> [Session started at 2008-05-15 15:34:38 +0530.]
> 2008-05-15 15:34:38.951 FileEnumerator[4094:10b] filepath is (Icon
> )
>
> FileEnumerator has exited with status 0.
>
> *Terminal View of Folder :*
>
> Janakirams-iMac-G5:~ janakiram$ cd /Users/janakiram/Downloads/
> Folder.tiff
>
> Janakirams-iMac-G5:Folder.tiff janakiram$ ls -la
> total 112
> drwxr-xr-x@ 3 janakiram staff 102 May 15 15:36 .
> drwx------+ 92 janakiram staff 3128 May 15 15:17 ..
> -rwxr-xr-x@ 1 janakiram staff 0 Aug 8 2006 Icon?
>
> Janakirams-iMac-G5:Folder.tiff janakiram$ cp -R Icon^M
DATE : Thu May 15 13:20:03 2008
This has to do with non-printable characters in pathnames. Each
application can different how they visually represent these
characters. The terminal just replaces them with '?', the Finder
might use a space.
When you have a path from NSFileManager, leave it as is in the
NSString if you're going to pass it to other Foundation file manager
APIs. If you need a C string of the path for C APIs, you can use
NSFileManager's fileSystemRepresentationWithPath: to get a properly
encoded C string. Also displayNameAtPath: can give you the proper
representation for displaying the path to the user but may not work
when passed to file system APIs.
On May 15, 2008, at 4:17 AM, JanakiRam wrote:
> I'm facing an issue with NSFileManger directoryContentsAtPath API.
> This
> seems to be an wried issue. But its very important for me to fix.
> Please
> help me.
>
> My application is trying to enumerate the folders in inside a Mac
> using NSFileManager API. But for some files its failing.
>
> It looks like the file name ( inside bundle ) is interpreted by
> Finder and
> Terminal in a different ways. Can any one please suggest me a way to
> resolve
> this issue.
>
> Thanks in Advance
>
> *Cocoa Code for your reference.*
>
> NSFileManager *defaultManager = [NSFileManager defaultManager];
> NSArray *filePath = [defaultManager directoryContentsAtPath:
> @"/Users/janakiram/Downloads/Folder.tiff"];
> int i , count = [filePath count];
>
> for ( i = 0 ; i < count ; i++ ) {
> NSLog(@" filepath is (%@)",[filePath objectAtIndex:i]);
>
> }
>
> *Output:*
>
> [Session started at 2008-05-15 15:34:38 +0530.]
> 2008-05-15 15:34:38.951 FileEnumerator[4094:10b] filepath is (Icon
> )
>
> FileEnumerator has exited with status 0.
>
> *Terminal View of Folder :*
>
> Janakirams-iMac-G5:~ janakiram$ cd /Users/janakiram/Downloads/
> Folder.tiff
>
> Janakirams-iMac-G5:Folder.tiff janakiram$ ls -la
> total 112
> drwxr-xr-x@ 3 janakiram staff 102 May 15 15:36 .
> drwx------+ 92 janakiram staff 3128 May 15 15:17 ..
> -rwxr-xr-x@ 1 janakiram staff 0 Aug 8 2006 Icon?
>
> Janakirams-iMac-G5:Folder.tiff janakiram$ cp -R Icon^M
| Related mails | Author | Date |
|---|---|---|
| JanakiRam | May 15, 12:17 | |
| Jean-Daniel Dupas | May 15, 13:04 | |
| Graham Cox | May 15, 13:11 | |
| Michael Vannorsdel | May 15, 13:20 | |
| JanakiRam | May 16, 07:02 | |
| Jean-Daniel Dupas | May 16, 14:12 | |
| Hamish Allan | May 16, 16:04 | |
| JanakiRam | May 16, 16:28 | |
| Hamish Allan | May 16, 16:45 | |
| Jens Alfke | May 16, 18:32 | |
| Michael Vannorsdel | May 16, 18:41 |






Cocoa mail archive

