[RFC] case sensitivity on Windows
bialix at ukr.net
Fri Oct 31 11:20:38 GMT 2008
Paul Moore пишет:
> 2008/10/31 Martin Pool <mbp at canonical.com>:
>> +def _win32_canonical_relpath(base, path):
>> + """Return the canonical path relative to base.
>> + Like relpath, but on case-insensitive-case-preserving file-systems, this
>> + will return the relpath as stored on the file-system rather than
>> in the case
>> + specified in the input string, for all existing portions of the path.
>> + TODO: it should be possible to optimize this by using the win32 API
>> + FindFiles function to look for the specified name - but using os.listdir()
>> + still gives us the correct semantics in the short term.
>> + """
>> So this routine, as it currently stands, is not win32-specific (aside
>> from the comment), but in fact is the kind of thing we'd like to also
>> use on os x or linux case-insensitive filesystems. So even if we're
>> not handling those cases at present, I'd name it accordingly,
>> cicp_canonical_relpath or something. That also gets away a bit from
>> assuming the canonical relpath algorithm is determined only by the
>> platform, when in fact it seems like it may vary per tree (eg in the
>> vfat on linux case).
> Just a brief note here - I did some similar code for Mercurial, and I
> found that actually, using os.listdir plus cacheing the results (so
> that I didn't call os.listdir more than once per directory) was
> actually faster than using win32 FindFile calls.
I'm very surprised about this moment, because internally os.listdir uses
FindFile Win32 API. Perhaps this overhead added by pywin32 wrapper?
More information about the bazaar