[Python-Dev] ntpath r54364 (original) (raw)
Tim Golden mail at timgolden.me.uk
Thu Jan 17 20:51:08 CET 2008
- Previous message: [Python-Dev] ntpath r54364 (was: PEP 370, open questions)
- Next message: [Python-Dev] ntpath r54364
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christian Heimes wrote:
Paul Moore wrote:
I'd recommend that this change be reverted. To correctly get another user's home directory would involve reading (via the registry, or maybe some utility function I couldn't find at a quick glance) the value of HOMEDRIVE/HOMEPATH which is set for the other user. (In fact, given that I guess these could be set in a login script, it's entirely possible that the information simply isn't available). I concur! The changes should be reverted. The implementation is most likely to fail in more elaborate cases, e.g. c:\users\a\alpha or c:\users\groupa\name. The proper way for a ~user implementation is a bunch of Win32 API calls.
Frustratingly, I don't believe there's any canonical way to find ~user without actually going through the whole process of getting a token and impersonating them. If they've logged onto this machine already you can have a good go by following the code posted the other day on c.l.py [1] (although I'm now not sure about the l10n aspects which Christian mentioned). Any technique of going up one (from your own profile) and then down one is no better than assuming that all users are in /home on a *nix box.
As to a logged-on user's own home path, I'd prefer HOMEDRIVE/PATH over USERPROFILE since the latter is at least explictly named HOMEsomething, although the latter can be the fallback. Both are present on Win2k & on WinXP. Can't check WinNT or Win9x but I don't know if we're looking to support those or not.
TJG
[1] http://groups.google.com/group/comp.lang.python/msg/71b20a67a9ca76dd
- Previous message: [Python-Dev] ntpath r54364 (was: PEP 370, open questions)
- Next message: [Python-Dev] ntpath r54364
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]