summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbtimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f>2012-09-17 19:16:48 +0000
committerbtimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f>2012-09-17 19:16:48 +0000
commitf8bfcdcb2f117d84c86ab6e5aab186e099cf0ba1 (patch)
treeee9675edaa32314dc84e7d7d848d5d73f791a5f8
parentbeef624d77ae98d5a1d2d718acc17560aebed59c (diff)
downloadpyfilesystem-f8bfcdcb2f117d84c86ab6e5aab186e099cf0ba1.tar.gz
Under some conditions, these methods are required. However, there was a bug in
isfile(). It did not properly handle the case of a path within a mountable archive. git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@819 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r--fs/contrib/archivefs.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/contrib/archivefs.py b/fs/contrib/archivefs.py
index 3292601..0557a0e 100644
--- a/fs/contrib/archivefs.py
+++ b/fs/contrib/archivefs.py
@@ -267,6 +267,28 @@ class ArchiveMountFS(mountfs.MountFS):
return info
return super(ArchiveMountFS, self).getinfo(path)
+ def isdir(self, path):
+ """An isdir() override that allows archives to masquerade as directories. If
+ the path is not an archive, the call is delegated. In the event that the path
+ is an archive, that archive is mounted to ensure it can actually be treated
+ like a directory."""
+ fs, _mount_path, delegate_path = self._delegate(path)
+ if isinstance(fs, ArchiveFS) and path == _mount_path:
+ # If the path is an archive mount point, it is a directory.
+ return True
+ return super(ArchiveMountFS, self).isdir(path)
+
+ def isfile(self, path):
+ """An isfile() override that checks if the given path is a file or not. It is
+ not fooled by a mounted archive. If the path is not an archive, True is returned.
+ If the path is not an archive, the call is delegated."""
+ fs, _mount_path, delegate_path = self._delegate(path)
+ if isinstance(fs, ArchiveFS) and path == _mount_path:
+ # If the path is an archive mount point, it is a file.
+ return True
+ else:
+ return fs.isfile(delegate_path)
+
def getsize(self, path):
"""A getsize() override that returns the size of an archive. It is not fooled by
a mounted archive. If the path is not an archive, the call is delegated."""