Re: File system case sensitivity
Re: File system case sensitivity
- Subject: Re: File system case sensitivity
- From: Chris Parker <email@hidden>
- Date: Sat, 18 Jun 2005 10:31:05 -0700
On Jun 18, 2005, at 8:30 AM, Jonathan Fewtrell wrote:
My app reads third-party data supplied on CD. The CDs are in ISO
9660 format (does this matter?). The files and folders follow a
strict naming pattern, and, relying on this, my app uses NSString
path methods to find particular files on the CD and copy them to
hard disk (HFS+ format). Originally, CDs were supplied with all
file and folder names in upper case and I wrote my code
accordingly, but I have now found that sometimes lower case is
used. I thought (OK, hoped) that, because the OS X file system is
case insensitive, my original code would still work. It doesn't.
For example:
File on CD used to be named README.TXT. Now it is readme.txt;
cdName is the name of the CD volume;
README and TXT are defined as @"README" and @"TXT" respectively.
Filesystems are case-insensitive or case-insensitive depending on
what semantics the filesystem itself defines.
HFS+ is case-insensitive and case-preserving.
NTFS is case-insensitive and case-preserving (if I recall correctly).
UFS is case-sensitive.
ISO9600 is case-sensitive.
Case-preserving is (sort of) a funny thing - if you've got a file
"readme.txt" and you rename it "readMe.TxT" that works.
If you have a file named "readme.txt" and you try to save a new file
called "READme.TXT" in the same directory, it'll collide, though -
they're the same name once you smash case.
Someone's changed the disk and the file you're asking for doesn't
have the same name that it used to.
A typical bit of my code might be:
NSString *path;
path = [[cdName stringByAppendingPathComponent:README]
stringByAppendingPathExtension:TXT];
[[NSFileManager defaultManager] fileExistsAtPath:path] previously
returned YES; now it returns NO.
Any guidance on this would be much appreciated. I don't know
whether my problem lies with NSString, NSFileManager, the fact that
the CD is in ISO 9660 format or a simple misunderstanding on my
part of the meaning of 'case insensitive'. I am hoping I don't have
to write tons of extra code just to cope with the fact that some
CDs are using upper case and some lower.
Well, if these are CDs for which you have control or communication
with the source of the data, suggesting that they're consistent in
their discipline for case is one approach. :)
If you're dealing with third party CDs over which you have no
control, you probably want to consider using something like directory
enumeration (see NSDirectoryEnumerator - it's much faster than it
used to be) and downcase the filenames you get (i.e. make it
effectively case-insensitive for your purposes).
.chris
--
Chris Parker
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden