268
273
Returned value can be unicode or plain string.
269
274
To convert plain string to unicode use
270
s.decode(bzrlib.user_encoding)
275
s.decode(osutils.get_user_encoding())
271
276
(XXX - but see bug 262874, which asserts the correct encoding is 'mbcs')
273
278
local = _get_sh_special_folder_path(CSIDL_LOCAL_APPDATA)
462
467
or appname itself if nothing found.
472
if not os.path.splitext(basename)[1]:
473
basename = appname + '.exe'
466
476
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
467
r'SOFTWARE\Microsoft\Windows'
468
r'\CurrentVersion\App Paths')
477
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\' +
469
479
except EnvironmentError:
473
if not os.path.splitext(basename)[1]:
474
basename = appname + '.exe'
477
fullpath = _winreg.QueryValue(hkey, basename)
484
path, type_id = _winreg.QueryValueEx(hkey, '')
478
485
except WindowsError:
481
488
_winreg.CloseKey(hkey)
490
if type_id == REG_SZ:
492
if type_id == REG_EXPAND_SZ and has_win32api:
493
fullpath = win32api.ExpandEnvironmentStrings(path)
494
if len(fullpath) > 1 and fullpath[0] == '"' and fullpath[-1] == '"':
495
fullpath = fullpath[1:-1] # remove quotes around value
486
500
def set_file_attr_hidden(path):
487
501
"""Set file attributes to hidden if possible"""
488
502
if has_win32file:
489
win32file.SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
503
if winver != 'Windows 98':
504
SetFileAttributes = win32file.SetFileAttributesW
506
SetFileAttributes = win32file.SetFileAttributes
508
SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
509
except pywintypes.error, e:
510
from bzrlib import trace
511
trace.mutter('Unable to set hidden attribute on %r: %s', path, e)
492
514
if has_ctypes and winver != 'Windows 98':