Problem with case insensitive volumes

Dave Angel davea at ieee.org
Tue May 5 00:33:22 EDT 2009


dmoore wrote:
> Does anyone know of a way to get the unique pathname for files stored
> on FAT32 or other case insensitive drives?
>
> For example:
>
> os.path.samefile('/media/usbkey/file1.jpg','/media/usbkey/FILE1.jpg')
>
> returns True
>
> but, is there a simple way to determine whether '/media/usbkey/
> file1.jpg' or '/media/usbkey/FILE1.jpg' is the actual representation
> on the device.
>
> it matters because operations like this have meaning:
>
> os.rename('/media/usbkey/file1.jpg','/media/usbkey/tmp')
> os.rename('/media/usbkey/tmp','/media/usbkey/FILE1.jpg')
>
> If I have a program that scans a directory for files and compares
> against a stored list of pathnames, I want to be able to determine not
> only that the file still exists but whether or not it has changed case
> (i.e. '/media/usbkey/file1.jpg' has become '/media/usbkey/FILE1.jpg').
>
> Any takers?
>
>   
os;walk will tell you the correct case for each node.   So if it gives 
you a different case than the stored form, you have your answer.





More information about the Python-list mailing list