comparison 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
comparison
equal deleted inserted replaced
2283:e506c14382fd 2284:d6392a7c03dd
14 import win32api 14 import win32api
15 15
16 from demandload import * 16 from demandload import *
17 from i18n import gettext as _ 17 from i18n import gettext as _
18 demandload(globals(), 'errno os pywintypes win32con win32file win32process') 18 demandload(globals(), 'errno os pywintypes win32con win32file win32process')
19 demandload(globals(), 'cStringIO winerror') 19 demandload(globals(), 'cStringIO win32com.shell:shell,shellcon winerror')
20 20
21 class WinError: 21 class WinError:
22 winerror_map = { 22 winerror_map = {
23 winerror.ERROR_ACCESS_DENIED: errno.EACCES, 23 winerror.ERROR_ACCESS_DENIED: errno.EACCES,
24 winerror.ERROR_ACCOUNT_DISABLED: errno.EACCES, 24 winerror.ERROR_ACCOUNT_DISABLED: errno.EACCES,
181 '''return default os-specific hgrc search path''' 181 '''return default os-specific hgrc search path'''
182 proc = win32api.GetCurrentProcess() 182 proc = win32api.GetCurrentProcess()
183 filename = win32process.GetModuleFileNameEx(proc, 0) 183 filename = win32process.GetModuleFileNameEx(proc, 0)
184 return [os.path.join(os.path.dirname(filename), 'mercurial.ini')] 184 return [os.path.join(os.path.dirname(filename), 'mercurial.ini')]
185 185
186 def user_rcpath():
187 '''return os-specific hgrc search path to the user dir'''
188 userdir = os.path.expanduser('~')
189 if userdir == '~':
190 # We are on win < nt: fetch the APPDATA directory location and use
191 # the parent directory as the user home dir.
192 appdir = shell.SHGetPathFromIDList(
193 qshell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_APPDATA))
194 userdir = os.path.dirname(appdir)
195 return os.path.join(userdir, 'mercurial.ini')
196
186 class posixfile_nt(object): 197 class posixfile_nt(object):
187 '''file object with posix-like semantics. on windows, normal 198 '''file object with posix-like semantics. on windows, normal
188 files can not be deleted or renamed if they are open. must open 199 files can not be deleted or renamed if they are open. must open
189 with win32file.FILE_SHARE_DELETE. this flag does not exist on 200 with win32file.FILE_SHARE_DELETE. this flag does not exist on
190 windows < nt, so do not use this class there.''' 201 windows < nt, so do not use this class there.'''