summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2010-01-08 03:47:16 +0000
committerrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2010-01-08 03:47:16 +0000
commit82223948be0ff6d8e6ca4ea296e0384675d6ae7b (patch)
treedbcb1c23a457e5a863d384a943ccfd71b158fa10
parent2cafbe3198c601c155659d8510239c326896e24c (diff)
downloadpyfilesystem-git-82223948be0ff6d8e6ca4ea296e0384675d6ae7b.tar.gz
OSFS.rename() - catch ENOTEMPTY and convert to UnsupportedError
-rw-r--r--fs/osfs.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/osfs.py b/fs/osfs.py
index 9d42eee..74c7741 100644
--- a/fs/osfs.py
+++ b/fs/osfs.py
@@ -177,7 +177,16 @@ class OSFS(FS):
def rename(self, src, dst):
path_src = self.getsyspath(src)
path_dst = self.getsyspath(dst)
- os.rename(path_src, path_dst)
+ try:
+ os.rename(path_src, path_dst)
+ except OSError, e:
+ # Linux (at least) can rename over an empty directory but gives
+ # ENOTEMPTY if the dir has contents. Raise UnsupportedError
+ # instead of DirectoryEmptyError in this case.
+ if e.errno and e.errno == errno.ENOTEMPTY:
+ raise UnsupportedError("rename")
+ raise
+
def _stat(self,path):
"""Stat the given path, normalising error codes."""