diff options
author | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2009-06-03 09:06:12 +0000 |
---|---|---|
committer | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2009-06-03 09:06:12 +0000 |
commit | 19f64480bf02aebba48154e3cabcde6270049570 (patch) | |
tree | 424ca3e8f4276c6c8f82773dcad7d99359b79acd | |
parent | 4f71e99e388b0cd6cb4fea2503719d0e00958bb3 (diff) | |
download | pyfilesystem-19f64480bf02aebba48154e3cabcde6270049570.tar.gz |
use proper stat functions for isfile/isdir
git-svn-id: http://pyfilesystem.googlecode.com/svn/branches/rfk-ideas@147 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r-- | fs/sftpfs.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/sftpfs.py b/fs/sftpfs.py index 79a8fee..fcfe169 100644 --- a/fs/sftpfs.py +++ b/fs/sftpfs.py @@ -5,6 +5,7 @@ """ import datetime +import stat as statinfo import paramiko @@ -113,25 +114,24 @@ class SFTPFS(FS): return True def isdir(self,path): - # TODO: there must be a better way to distinguish files and directories npath = self._normpath(path) try: - self.client.listdir(npath) - return True + stat = self.client.stat(npath) except IOError, e: if getattr(e,"errno",None) == 2: return False raise OperationFailedError("isdir",path,details=e) + return statinfo.S_ISDIR(stat) def isfile(self,path): npath = self._normpath(path) try: - self.client.listdir(npath) - return False + stat = self.client.stat(npath) except IOError, e: if getattr(e,"errno",None) == 2: - return self.exists(path) + return False raise OperationFailedError("isfile",path,details=e) + return statinfo.S_ISREG(stat) def listdir(self,path="./",wildcard=None,full=False,absolute=False,dirs_only=False,files_only=False): npath = self._normpath(path) |