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