[RFC] case sensitivity on Windows
Paul Moore
p.f.moore at gmail.com
Fri Oct 31 09:16:20 GMT 2008
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 can't recall the
exact details (it may have been caused by the specific calling
patterns I encountered) but I'd suggest profiling the results before
doing something OS-specific (particularly since, as Martin points out,
it's not actually an OS-specific problem, but rather a FS-specific
one).
Paul
More information about the bazaar
mailing list