Example #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())
Example #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
Example #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
Example #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
Example #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")
Example #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
Example #7
0
 def link(self, source, to, fs, state):
     raise exceptions.FileExists(to)
Example #8
0
 def create_file(self, path):
     raise exceptions.FileExists(path)
Example #9
0
 def create_directory(self, path, with_parents):
     raise exceptions.FileExists(path)
Example #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)