From: Brian Warner Date: Wed, 25 Feb 2009 00:55:22 +0000 (-0700) Subject: scripts/common: on windows, tolerate paths like 'c:\dir\file.txt', by treating single... X-Git-Url: https://git.rkrishnan.org/index.html?a=commitdiff_plain;h=a0aea06a9edf6c76c2b340758420df768ce76e23;p=tahoe-lafs%2Ftahoe-lafs.git scripts/common: on windows, tolerate paths like 'c:\dir\file.txt', by treating single-letter aliases on windows/cygwin as non-aliases --- diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index 8518c6a0..c06f7a10 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -116,6 +116,14 @@ def get_aliases(nodedir): class DefaultAliasMarker: pass +pretend_platform_uses_lettercolon = False # for tests +def platform_uses_lettercolon_drivename(): + if ("win32" in sys.platform.lower() + or "cygwin" in sys.platform.lower() + or pretend_platform_uses_lettercolon): + return True + return False + def get_alias(aliases, path, default): # transform "work:path/filename" into (aliases["work"], "path/filename"). # If default=None, then an empty alias is indicated by returning @@ -135,6 +143,10 @@ def get_alias(aliases, path, default): if default == None: return DefaultAliasMarker, path return aliases[default], path + if colon == 1 and platform_uses_lettercolon_drivename(): + # treat C:\why\must\windows\be\so\weird as a local path, not a tahoe + # file in the "C:" alias + return DefaultAliasMarker, path alias = path[:colon] if "/" in alias: # no alias, but there's a colon in a dirname/filename, like