summaryrefslogtreecommitdiff
path: root/fs/osfs
diff options
context:
space:
mode:
authorrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2011-01-08 02:02:03 +0000
committerrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2011-01-08 02:02:03 +0000
commit278b48d5be117855212df04853b64d626a33b8e6 (patch)
tree5bb923ed2aa20fcbc86b8f950ff6cf12c49bb00e /fs/osfs
parentfc0f2037252a7bd4caeb2e7edb8cd7c72e7f4034 (diff)
downloadpyfilesystem-278b48d5be117855212df04853b64d626a33b8e6.tar.gz
(hopefully) fix handling of remote UNC paths in OSFS
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@605 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/osfs')
-rw-r--r--fs/osfs/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/osfs/__init__.py b/fs/osfs/__init__.py
index 119d42d..b6fb345 100644
--- a/fs/osfs/__init__.py
+++ b/fs/osfs/__init__.py
@@ -84,7 +84,7 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
'atomic.setcontents' : False,
}
- def __init__(self, root_path, thread_synchronize=_thread_synchronize_default, encoding=None, create=False, dir_mode=0700):
+ def __init__(self, root_path, thread_synchronize=_thread_synchronize_default, encoding=None, create=False, dir_mode=0700, use_long_paths=True):
"""
Creates an FS object that represents the OS Filesystem under a given root path
@@ -99,14 +99,18 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
super(OSFS, self).__init__(thread_synchronize=thread_synchronize)
self.encoding = encoding or sys.getfilesystemencoding()
self.dir_mode = dir_mode
+ self.use_long_paths = use_long_paths
root_path = os.path.expanduser(os.path.expandvars(root_path))
root_path = os.path.normpath(os.path.abspath(root_path))
# Enable long pathnames on win32
if sys.platform == "win32":
- if not root_path.startswith("\\\\?\\"):
- root_path = u"\\\\?\\" + root_path
+ if use_long_paths and not root_path.startswith("\\\\?\\"):
+ if not root_path.startswith("\\"):
+ root_path = u"\\\\?\\" + root_path
+ else:
+ root_path = u"\\\\?" + root_path
# If it points at the root of a drive, it needs a trailing slash.
- if len(root_path) == 6:
+ if len(root_path) == 6 and not root_path.endswith("\\"):
root_path = root_path + "\\"
if create: