Exemplo n.º 1
0
 def openForReading(self, path):
     """
     Open file at C{path} for reading.
     """
     try:
         node = self.filesystem.fetch(self._makePath(path))
         if ivfs.IFileSystemContainer.providedBy(node):
             raise ftp.IsADirectoryError("Can only open file for reading.")
     except ivfs.VFSError, e:
         return vfsToFtpError(e)
Exemplo n.º 2
0
 def removeFile(self, path):
     """
     Remove the file at C{path}.
     """
     try:
         node = self.filesystem.fetch(self._makePath(path))
         if not ivfs.IFileSystemLeaf.providedBy(node):
             raise ftp.IsADirectoryError(
                 "removeFile can only remove files.")
         node.remove()
     except ivfs.VFSError, e:
         return vfsToFtpError(e)
Exemplo n.º 3
0
 def openForWriting(self, path):
     """
     Open file at C{path} for writing.
     """
     if len(path) == 1:
         path = ('.', path[0])
     dirname, basename = path[:-1], path[-1]
     try:
         node = self.filesystem.fetch(self._makePath(dirname))
         if (node.exists(basename) and ivfs.IFileSystemContainer.providedBy(
                 node.child(basename))):
             raise ftp.IsADirectoryError("Can only open file for writing.")
         node = node.createFile(basename, exclusive=False)
     except ivfs.VFSError, e:
         return vfsToFtpError(e)
Exemplo n.º 4
0
 def openForReading(self, path):
     '''
     Overwrite openForReading of ftp.FTPAnonymousShell,
     make it support ftp_REST
     '''
     p = self._path(path)
     if p.isdir():
         # Normally, we would only check for EISDIR in open, but win32
         # returns EACCES in this case, so we check before
         return defer.fail(ftp.IsADirectoryError(path))
     try:
         f = p.open('rb')
         if self.pos != 0:
             f.seek(self.pos, 0)
             self.pos = 0
     except (IOError, OSError), e:
         return ftp.errnoToFailure(e.errno, path)
Exemplo n.º 5
0
 def openForWriting(self, path):
     '''
     Overwrite openForReading of ftp.FTPShell,
     make it support ftp_APPE
     '''
     p = self._path(path)
     if p.isdir():
         # Normally, we would only check for EISDIR in open, but win32
         # returns EACCES in this case, so we check before
         return defer.fail(ftp.IsADirectoryError(path))
     try:
         if self.append:
             fObj = p.open('ab')
             self.append = False
         else:
             fObj = p.open('wb')
     except (IOError, OSError), e:
         return ftp.errnoToFailure(e.errno, path)
Exemplo n.º 6
0
 def _got_child(child):
     if must_be_directory and not IDirectoryNode.providedBy(child):
         raise ftp.IsNotADirectoryError("rmdir called on a file")
     if must_be_file and IDirectoryNode.providedBy(child):
         raise ftp.IsADirectoryError("rmfile called on a directory")
     return parent.delete(childname)