/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: Andrew Bennetts
  • Date: 2009-06-17 02:02:44 UTC
  • mfrom: (4449 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4452.
  • Revision ID: andrew.bennetts@canonical.com-20090617020244-50aantdf95aakvjx
Merge bzr.dev, resolving NEWS conflict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
267
267
 
268
268
    Returned value can be unicode or plain string.
269
269
    To convert plain string to unicode use
270
 
    s.decode(bzrlib.user_encoding)
 
270
    s.decode(osutils.get_user_encoding())
271
271
    (XXX - but see bug 262874, which asserts the correct encoding is 'mbcs')
272
272
    """
273
273
    local = _get_sh_special_folder_path(CSIDL_LOCAL_APPDATA)
433
433
    import glob
434
434
    expanded_file_list = []
435
435
    for possible_glob in file_list:
436
 
 
437
436
        # work around bugs in glob.glob()
438
437
        # - Python bug #1001604 ("glob doesn't return unicode with ...")
439
438
        # - failing expansion for */* with non-iso-8859-* chars
488
487
    """Set file attributes to hidden if possible"""
489
488
    if has_win32file:
490
489
        win32file.SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
 
490
 
 
491
 
 
492
if has_ctypes and winver != 'Windows 98':
 
493
    def get_unicode_argv():
 
494
        LPCWSTR = ctypes.c_wchar_p
 
495
        INT = ctypes.c_int
 
496
        POINTER = ctypes.POINTER
 
497
        prototype = ctypes.WINFUNCTYPE(LPCWSTR)
 
498
        GetCommandLine = prototype(("GetCommandLineW",
 
499
                                    ctypes.windll.kernel32))
 
500
        prototype = ctypes.WINFUNCTYPE(POINTER(LPCWSTR), LPCWSTR, POINTER(INT))
 
501
        CommandLineToArgv = prototype(("CommandLineToArgvW",
 
502
                                       ctypes.windll.shell32))
 
503
        c = INT(0)
 
504
        pargv = CommandLineToArgv(GetCommandLine(), ctypes.byref(c))
 
505
        # Skip the first argument, since we only care about parameters
 
506
        argv = [pargv[i] for i in range(1, c.value)]
 
507
        if getattr(sys, 'frozen', None) is None:
 
508
            # Invoked via 'python.exe' which takes the form:
 
509
            #   python.exe [PYTHON_OPTIONS] C:\Path\bzr [BZR_OPTIONS]
 
510
            # we need to get only BZR_OPTIONS part,
 
511
            # so let's using sys.argv[1:] as reference to get the tail
 
512
            # of unicode argv
 
513
            tail_len = len(sys.argv[1:])
 
514
            ix = len(argv) - tail_len
 
515
            argv = argv[ix:]
 
516
        return argv
 
517
else:
 
518
    get_unicode_argv = None