示例#1
0
    def create_directory(self, path):
        if self.exists(path=path):
            raise exceptions.FileExists(path)

        parent = path.parent()
        if not self.exists(path=parent):
            raise exceptions.FileNotFound(parent)

        self._tree = self._tree.set(path, pmap())
示例#2
0
def _create_directory(fs, path):
    try:
        os.mkdir(str(path))
    except (IOError, OSError) as error:
        if error.errno == exceptions.FileNotFound.errno:
            raise exceptions.FileNotFound(path.parent())
        elif error.errno == exceptions.FileExists.errno:
            raise exceptions.FileExists(path)
        raise
示例#3
0
def _link(fs, source, to):
    try:
        os.symlink(str(source), str(to))
    except (IOError, OSError) as error:
        if error.errno == exceptions.FileNotFound.errno:
            raise exceptions.FileNotFound(to.parent())
        elif error.errno == exceptions.NotADirectory.errno:
            raise exceptions.NotADirectory(to.parent())
        elif error.errno == exceptions.FileExists.errno:
            raise exceptions.FileExists(to)
        raise
示例#4
0
    def create_file(self, path):
        if self.exists(path=path) or self.is_link(path=path):
            raise exceptions.FileExists(path)

        path = self.realpath(path=path)
        parent = path.parent()
        contents = self._tree.get(parent)
        if contents is None:
            raise exceptions.FileNotFound(path)
        file = _BytesIOIsTerrible()
        self._tree = self._tree.set(parent, contents.set(path, file))
        return file
示例#5
0
def _create_file(fs, path):
    try:
        fd = os.open(str(path), _CREATE_FLAGS)
    except (IOError, OSError) as error:
        if error.errno == exceptions.FileNotFound.errno:
            raise exceptions.FileNotFound(path)
        elif error.errno == exceptions.FileExists.errno:
            raise exceptions.FileExists(path)
        elif error.errno == exceptions.SymbolicLoop.errno:
            raise exceptions.SymbolicLoop(path.parent())
        raise

    return os.fdopen(fd, "w+b")
示例#6
0
def _create_directory(fs, path, with_parents):
    try:
        if with_parents:
            os.makedirs(str(path))
        else:
            os.mkdir(str(path))
    except (IOError, OSError) as error:
        if error.errno == exceptions.FileExists.errno:
            raise exceptions.FileExists(path)
        elif error.errno == exceptions.FileNotFound.errno:
            raise exceptions.FileNotFound(path.parent())
        elif error.errno == exceptions.NotADirectory.errno:
            raise exceptions.NotADirectory(path.parent())
        elif error.errno == exceptions.SymbolicLoop.errno:
            raise exceptions.SymbolicLoop(path.parent())
        raise
示例#7
0
 def link(self, source, to, fs, state):
     raise exceptions.FileExists(to)
示例#8
0
 def create_file(self, path):
     raise exceptions.FileExists(path)
示例#9
0
 def create_directory(self, path, with_parents):
     raise exceptions.FileExists(path)
示例#10
0
 def link(self, source, to):
     if self.exists(path=to) or self.is_link(path=to):
         raise exceptions.FileExists(to)
     self._tree = self._tree_with(path=to)
     self._links = self._links.set(to, source)