Mercurial > hg > mercurial-crew-with-dirclash
diff mercurial/util_win32.py @ 2284:d6392a7c03dd
On win98 os.path.expanuser('~') does not result in a useable directory.
The MSDN recommendation for user specific directories is the use of
shell.ShGetSpecialFolder, so use it.
For details see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetspecialfolderpath.asp
author | Volker Kleinfeld <Volker.Kleinfeld@gmx.de> |
---|---|
date | Sun, 14 May 2006 23:44:50 -0700 |
parents | 45aef5ddcdbe |
children | 0912f807b7ff |
line wrap: on
line diff
--- a/mercurial/util_win32.py +++ b/mercurial/util_win32.py @@ -16,7 +16,7 @@ import win32api from demandload import * from i18n import gettext as _ demandload(globals(), 'errno os pywintypes win32con win32file win32process') -demandload(globals(), 'cStringIO winerror') +demandload(globals(), 'cStringIO win32com.shell:shell,shellcon winerror') class WinError: winerror_map = { @@ -183,6 +183,17 @@ def system_rcpath_win32(): filename = win32process.GetModuleFileNameEx(proc, 0) return [os.path.join(os.path.dirname(filename), 'mercurial.ini')] +def user_rcpath(): + '''return os-specific hgrc search path to the user dir''' + userdir = os.path.expanduser('~') + if userdir == '~': + # We are on win < nt: fetch the APPDATA directory location and use + # the parent directory as the user home dir. + appdir = shell.SHGetPathFromIDList( + qshell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA)) + userdir = os.path.dirname(appdir) + return os.path.join(userdir, 'mercurial.ini') + class posixfile_nt(object): '''file object with posix-like semantics. on windows, normal files can not be deleted or renamed if they are open. must open