Example #1
0
    def rename(self, newName):
        newParent = pathutils.fetch(pathutils.getRoot(self),
                                    pathutils.dirname(newName))
        if newParent.exists(pathutils.basename(newName)):
            raise ivfs.AlreadyExistsError(
                "Cannot rename over the top of an existing directory")

        del self.parent._children[self.name]
        self.name = pathutils.basename(pathutils.basename(newName))
        newParent._children[self.name] = self
        self.parent = newParent
Example #2
0
    def rename(self, newName):
        newParent = pathutils.fetch(pathutils.getRoot(self),
                                    pathutils.dirname(newName))
        if newParent.exists(pathutils.basename(newName)):
            raise ivfs.AlreadyExistsError(
                "Cannot rename over the top of an existing directory")

        del self.parent._children[self.name]
        self.name = pathutils.basename(pathutils.basename(newName))
        newParent._children[self.name] = self
        self.parent = newParent
Example #3
0
    def rename(self, newName):
        """
        Rename this node to C{newName}.

        @param newName: A valid filename for the current directory.
        @raise AlreadyExistsError: If C{newName} is a directory which already
            exists.
        """
        from twisted.vfs import pathutils

        newParent = pathutils.fetch(pathutils.getRoot(self), pathutils.dirname(newName))
        # XXX spiv 2005-12-15
        # assumes newParent is also an OSDirectory.  Probably should politely
        # decline (rather than break with an undefined error) if it's not.
        newPath = os.path.join(newParent.realPath, pathutils.basename(newName))
        try:
            os.rename(self.realPath, newPath)
        except OSError, e:
            if e.errno in (errno.EISDIR, errno.ENOTEMPTY, errno.EEXIST):
                raise ivfs.AlreadyExistsError(
                    "Can't rename %s to %s: %s already exists" % (self.realPath, newPath, newPath)
                )
            else:
                raise
Example #4
0
    def rename(self, newName):
        """
        Rename this node to C{newName}.

        @param newName: A valid filename for the current directory.
        @raise AlreadyExistsError: If C{newName} is a directory which already
            exists.
        """
        from twisted.vfs import pathutils
        newParent = pathutils.fetch(pathutils.getRoot(self),
                                    pathutils.dirname(newName))
        # XXX spiv 2005-12-15
        # assumes newParent is also an OSDirectory.  Probably should politely
        # decline (rather than break with an undefined error) if it's not.
        newPath = os.path.join(newParent.realPath, pathutils.basename(newName))
        try:
            os.rename(self.realPath, newPath)
        except OSError, e:
            if e.errno in (errno.EISDIR, errno.ENOTEMPTY, errno.EEXIST):
                raise ivfs.AlreadyExistsError(
                    "Can't rename %s to %s: %s already exists"
                    % (self.realPath, newPath, newPath))
            else:
                raise