extended chars in paths, bug or other way to do it?
extended chars in paths, bug or other way to do it?
- Subject: extended chars in paths, bug or other way to do it?
- From: Glenn Howes <email@hidden>
- Date: Fri, 18 Oct 2002 12:13:00 -0500
I've put together the following routine to demonstrate a problem I've
been having with the NSFileManager.
When iTunes accesses an Audio CD's cddb entry, it makes the track names
available for the OS to give human readable track names to the fake
AIFF files which are presented to the file system when mounting the
Audio CD. So instead of "01 Track.aiff" it might say "1 Blue
Moon.aiff." What I want to do is locate a given AIFF file and hand it
off to QuickTime for playing, and 99% of the time this works fine.
However, you can have ISO-8859-1 aka NSISOLatin1StringEncoding
characters in the track name and iTunes puts them into the filename.
Thus, I've an Enya CD here whose 10th track is "10 La Soqadora.aiff"
(that's a tilde over the n) and when I create the path to this file,
the NSFileManager says it does not exist. Therefore, I can't make a
NSURL to the aiff and I can't create a QuickTime Movie, and I can't
play this track.
So, either this is a bug, and iTunes shouldn't be using extended
characters in the track names it hands off, or the NSFileManager is
obsolete and I should be using a different API or object to generate my
NSURL's or there is some other way to do it. I just noticed that the
Finder has the same problem: clicking on any of the other tracks on the
disk brings up the preview window with the QuickTime controller,
clicking on this oddly named track just brings up an AIFF document icon
with the descriptive text.
- (IBAction)doTest:(id)sender
{
NSWorkspace* theWorkSpace = [NSWorkspace sharedWorkspace];
NSArray* removableMedia = [theWorkSpace mountedRemovableMedia];
NSFileManager *theFileManager = [NSFileManager defaultManager];
if(removableMedia)
{
NSEnumerator *en = [removableMedia objectEnumerator];
NSString* aPath = nil;
while((aPath = [en nextObject])!= nil)
{
NSArray* dirContents =[theFileManager
directoryContentsAtPath:aPath];
NSEnumerator* dirEnumerator = [dirContents
objectEnumerator];
NSString* fileName = nil;
while(nil != (fileName = [dirEnumerator nextObject]))
{
NSString* subPath = [aPath
stringByAppendingPathComponent:fileName];
if(![theFileManager fileExistsAtPath:subPath])
{
NSRunCriticalAlertPanel(
NSLocalizedString
(@"A file on the CD cannot be accessed.",
@""),
subPath,
NSLocalizedString (@"OK", @""),
nil, nil);
}
}
}
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.