def create(self, path): self.cleanUp() self.blkdev = BlkDevFactory().create(path) self.volume = ADFSVolume(self.blkdev) name = os.path.basename(path) self.volume.create(make_fsstr(name), dos_type=None)
def insert(self, input): name = os.path.basename(input) if os.path.isfile(input): fh = open(input, 'rb') data = fh.read() fh.close() self.volume.write_file(data, make_fsstr(self.path), make_fsstr(name)) elif os.path.isdir(input): parent, name = self.volume.get_create_path_name( make_fsstr(self.path), make_fsstr(name)) node = parent.create_dir(name) img = Imager(meta_mode=Imager.META_MODE_NONE) img.pack_dir(input, node) self.navigate(self.path)
def extract(self, name, output): path = self.absolutePath(name) node = self.volume.get_path_name(make_fsstr(path)) if node.is_file(): data = node.get_file_data() fh = open(output, 'wb') fh.write(data) fh.close() elif node.is_dir(): img = Imager(meta_mode=Imager.META_MODE_NONE) img.unpack_dir(node, output)
def navigate(self, path='/'): try: self.node = self.volume.get_path_name(make_fsstr(path)) except: return self.path = path self.entries = [{ 'name': entry.get_file_name().get_name().__str__(), 'type': 'dir' if entry.is_dir() else 'file' } for entry in self.node.get_entries_sorted_by_name()] self.app.updatePath(self.path) self.app.updateBrowser(self.entries)
def relabel(self, name): self.volume.relabel(make_fsstr(name))
def delete(self, name): path = self.absolutePath(name) self.volume.delete(make_fsstr(path), all=True) self.navigate(self.path)
def makeDir(self, name): path = self.absolutePath(name) self.volume.create_dir(make_fsstr(path)) self.navigate(self.path)