From 3bd6eb3991c8864033146093139d2a52057c9a53 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 4 May 2015 14:21:31 +0200 Subject: [PATCH] Glob: Fix file path manipulation on windows --- coalib/parsing/Glob.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/coalib/parsing/Glob.py b/coalib/parsing/Glob.py index 5bc629fe43..e4b7ae4683 100644 --- a/coalib/parsing/Glob.py +++ b/coalib/parsing/Glob.py @@ -197,9 +197,14 @@ def iglob(pattern, files=True, dirs=True): raise StopIteration() for pat in _iter_or_combinations(pattern): - pattern_parts = pat.split(os.sep) # "/a/b.py" -> ['', 'a', 'b.py'] + # extract drive letter, if possible: + drive_letter, pat = os.path.splitdrive(pat) + # "/a/b.py" -> ['', 'a', 'b.py'] or \\a\\b.py -> ['', 'a', 'b.py'] + pattern_parts = pat.split(os.sep) + # replace first pattern part with absolute path root if empty if pat.startswith(os.sep): - pattern_parts[0] = os.sep # would be '' instead + pattern_parts[0] = drive_letter and drive_letter + "\\" or os.sep + selector = _make_selector(pattern_parts) for p in selector.collect():