Re: How can I standardize a path name?
Re: How can I standardize a path name?
- Subject: Re: How can I standardize a path name?
- From: Rainer Brockerhoff <email@hidden>
- Date: Thu, 24 Jan 2002 22:32:27 -0200
>
Date: Thu, 24 Jan 2002 14:26:21 -0700
>
From: Doug Simons <email@hidden>
>
>
I'm trying to find a way to get a full standardized path name for a
>
file. The difficulty is related to HFS+ and Apple's file extension
>
hiding mechanism.
>
...
>
HFS+ will allow me to access the file using either the upper- or
>
lower-case version of the name, but I need a way to know how it is
>
actually stored on the disk, so I don't open it twice (and also so that
>
I can present the name to the user the way it appears in the file
>
system).
>
...
>
So, does anyone know a good, straightforward method of standardizing a
>
file path that will distinguish between "test", "TEST", "test.st", and
>
"TEST.st" if all of those files exist, but will yield the form of the
>
name as stored in the file system if only one case exists? To qualify
>
as a good answer, it must work on any file system supported by OS X and
>
ideally not require reading through the entire directory!
AFAIK, the only absolutely fool-proof method to check that two paths point at the same file - and one that also covers symbolic links, and uppercasing anywhere in the path name - is making a FSSpec for both and comparing the FSSpecs with FSCompareFSRefs(). To make a FSRef for a path, call FSPathMakeRef([pathName fileSystemRepresentation],&newFSRef,NULL).
You may want to pre-store FSRefs instead of paths for files you have opened, in your case.
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"I love deadlines. I love the whooshing noise they make as they go by" (Douglas Adams)
http://www.brockerhoff.net/ (updated Jan. 2002)