I think that, like os.path.realpath(), it should not fail if the file
does not exist.
Maybe the API could be called os.path.unnormpath(), since it is in a
sense the opposite of normpath() (which removes case) ? But I would
want to write it so that even on Unix it scans the filesystem, in case
the filesystem is case-preserving (like the default fs on OS X).
--Guido
On Fri, Sep 24, 2010 at 3:43 PM, Glenn Linderman
On 9/24/2010 3:10 PM, Greg Ewing wrote:
Paul Moore wrote:
I dug into this once, and as far as I could tell, it's possible to get the information on Windows, but there's no way on Linux to "ask the filesystem".
Maybe we could use a heuristic such as:
1) Search the directory for an exact match to the name given, return it if found.
2) Look for a match ignoring case. If one is found, test it to see if it refers to the same file as the given path, and if so return it.
3) Otherwise, raise an exception.
Hmm. There is no need for the function on a case sensitive file system, because the name had better be spelled with matching case: that is, if it is spelled with non-matching case it is an attempt to reference a non-existent file (or at least a different file).
So the API could do the "right thing" for case preserving or case ignoring file systems, but for case sensitive file systems, at most an existence check would be warranted.
In other words, the API, should it be created, should be "What is the actual name of the file that matches this if it exists in the filesystem", so the first check is to see if it exists in the file system (this may raise an exception if it doesn't exist), and then if it does, then on those filesystems for which it might be different, obtain the different name. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido)