~mandel/ubuntuone-client/fix-805372

« back to all changes in this revision

Viewing changes to ubuntuone/platform/windows/os_helper.py

  • Committer: Tarmac
  • Author(s): Manuel de la Pena
  • Date: 2011-06-30 15:38:48 UTC
  • mfrom: (1030.4.3 fix-803507)
  • Revision ID: tarmac-20110630153848-ypxgs3vv5ou66un8
The method os.listdir should not be used, use os_helper.listdir instead to ensure that the correct os.path.sep is appended to the path (LP: #803507).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from contextlib import contextmanager
28
28
from pywintypes import error as PyWinError
29
29
from win32api import GetUserName, GetFileAttributes
30
 
from win32file import FindFilesW, MoveFileExW
 
30
from win32file import MoveFileExW
31
31
from win32com.client import Dispatch
32
32
from pywintypes import error
33
33
from win32con import FILE_ATTRIBUTE_READONLY
493
493
    """List a directory."""
494
494
    # os.listdir combines / and \ in its search which breaks things on
495
495
    # windows, we use the win32 api instead.
496
 
    result = []
497
 
    for file_info in FindFilesW(os.path.join(directory, '*.*')):
498
 
        name = file_info[8]
499
 
        # ignore . and .. which windows returns and linux does not
500
 
        if name != '.' and name != '..':
501
 
            result.append(name)
502
 
    return result
503
 
 
 
496
    if not directory.endswith(os.path.sep):
 
497
        directory += os.path.sep
 
498
    return os.listdir(directory)
504
499
 
505
500
@longpath(paths_indexes=[0])
506
501
def access(path):