예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
 def relabel(self, name):
     self.volume.relabel(make_fsstr(name))
예제 #6
0
    def delete(self, name):
        path = self.absolutePath(name)

        self.volume.delete(make_fsstr(path), all=True)
        self.navigate(self.path)
예제 #7
0
    def makeDir(self, name):
        path = self.absolutePath(name)

        self.volume.create_dir(make_fsstr(path))
        self.navigate(self.path)