Comments
Patch
@@ -673,3 +673,9 @@ def bindunixsocket(sock, path):
if bakwdfd:
os.fchdir(bakwdfd)
os.close(bakwdfd)
+
+def absjoin(absprefix, relpath):
+ """Join a relative path to an absolute path. This function assumes that
+ the passed absolute path already contains a terminating directory
+ separator."""
+ return absprefix + relpath
@@ -150,6 +150,7 @@ testpid = platform.testpid
umask = platform.umask
unlink = platform.unlink
username = platform.username
+absjoin = platform.absjoin
try:
recvfds = osutil.recvfds
@@ -245,6 +245,28 @@ def normpath(path):
def normcase(path):
return encoding.upper(path) # NTFS compares via upper()
+def converttontpath(path):
+ """Prepend \\?\ prefix to a path and perform slash replacements
+ The '\\?\' prefix tells Win32 API to not perform userland path checks,
+ therefore allowing long paths. This also means that / are not replaced
+ with \ by Win32, so we need to do it manually. See MSDN entry on
+ CreateFile function for more details"""
+ return '\\\\?\\' + os.path.normpath(path)
+
+def hasntprefix(path):
+ """Check if path starts with a \\?\ prefix"""
+ return path.startswith('\\\\?\\')
+
+def absjoin(absprefix, relpath):
+ """See docblock for posix.absjoin for explanation of what this does."""
+ if hasntprefix(absprefix):
+ # we assume that if absprefix starts with \\?\, this means that it
+ # was already preprocessed by converttontpath and therefore does
+ # not need to passed to `localpath`
+ return absprefix + localpath(relpath)
+ else:
+ return converttontpath(absprefix + relpath)
+
# see posix.py for definitions
normcasespec = encoding.normcasespecs.upper
normcasefallback = encoding.upperfallback