コード例 #1
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
    def readdir(self, path, offset):
        log.info("readdir(%s)" % path)
        yield fuse.Direntry('.')
        yield fuse.Direntry('..')
        if path == "/.command":
            for entry in self.readCommandDir():
                yield entry
            return

        # Get field
        fieldset = self.getField(path)
#        if not fieldset:
#            return -errno.ENOENT

        if path == "/":
            entry = fuse.Direntry(".command")
            entry.type = stat.S_IFREG
            yield entry

        # Format file name
        count = len(fieldset)
        if count % 10:
            count += 10 - (count % 10)
        format = "%%0%ud-%%s" % (count//10)

        # Create entries
        for index, field in enumerate(fieldset):
            name = format % (1+index, field.name)
            entry = fuse.Direntry(name)
            if field.is_field_set:
                entry.type = stat.S_IFDIR
            else:
                entry.type = stat.S_IFREG
            yield entry
        log.info("readdir(%s) done" % path)
コード例 #2
0
    def readdir(self, path, offset):
        log.info("readdir(%s)" % path)
        yield fuse.Direntry('.')
        yield fuse.Direntry('..')
        if path == "/.command":
            for entry in self.readCommandDir():
                yield entry
            return

        # Get field
        fieldset = self.getField(path)
        #        if not fieldset:
        #            return -errno.ENOENT

        if path == "/":
            entry = fuse.Direntry(".command")
            entry.type = stat.S_IFREG
            yield entry

        # Format file name
        count = len(fieldset)
        if count % 10:
            count += 10 - (count % 10)
        format = "%%0%ud-%%s" % (count // 10)

        # Create entries
        for index, field in enumerate(fieldset):
            name = format % (1 + index, field.name)
            entry = fuse.Direntry(name)
            if field.is_field_set:
                entry.type = stat.S_IFDIR
            else:
                entry.type = stat.S_IFREG
            yield entry
        log.info("readdir(%s) done" % path)
コード例 #3
0
 def write(self, path, data, offset):
     if path == "/.command/writeInto":
         if self.readonly:
             return -errno.EACCES
         try:
             data = data.strip(" \t\r\n\0")
             filename = unicode(data, self.fs_charset)
         except UnicodeDecodeError:
             log.info("writeInto(): unicode error!")
             return 0
         log.info("writeInto(%s)" % filename)
         stream = FileOutputStream(filename)
         self.hachoir.writeInto(stream)
     return len(data)
コード例 #4
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def write(self, path, data, offset):
     if path == "/.command/writeInto":
         if self.readonly:
             return -errno.EACCES
         try:
             data = data.strip(" \t\r\n\0")
             filename = unicode(data, self.fs_charset)
         except UnicodeDecodeError:
             log.info("writeInto(): unicode error!")
             return 0
         log.info("writeInto(%s)" % filename)
         stream = FileOutputStream(filename)
         self.hachoir.writeInto(stream)
     return len(data)
コード例 #5
0
 def getField(self, path):
     try:
         field = self.hachoir
         try:
             for name in path.split("/")[1:]:
                 if not name:
                     break
                 name = name.split("-", 1)
                 if len(name) != 2:
                     return None
                 field = field[name[1]]
             return field
         except MissingField:
             return None
     except Exception, xx:
         log.info("Exception: %s" % str(xx))
         raise
コード例 #6
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def getField(self, path):
     try:
         field = self.hachoir
         try:
             for name in path.split("/")[1:]:
                 if not name:
                     break
                 name = name.split("-", 1)
                 if len(name) != 2:
                     return None
                 field = field[name[1]]
             return field
         except MissingField:
             return None
     except Exception, xx:
         log.info("Exception: %s" % str(xx))
         raise
コード例 #7
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def unlink(self, path, *args):
     log.info("unlink(%s)" % path)
     field = self.getField(path)
     log.info("del %s" % field.name)
     if not field:
         return -errno.ENOENT
     if self.readonly:
         return -errno.EACCES
     log.info("del %s" % field.name)
     try:
         del field.parent[field.name]
     except Exception, err:
         log.info("del ERROR %s" % err)
コード例 #8
0
 def unlink(self, path, *args):
     log.info("unlink(%s)" % path)
     field = self.getField(path)
     log.info("del %s" % field.name)
     if not field:
         return -errno.ENOENT
     if self.readonly:
         return -errno.EACCES
     log.info("del %s" % field.name)
     try:
         del field.parent[field.name]
     except Exception, err:
         log.info("del ERROR %s" % err)
コード例 #9
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def read(self, path, size, offset):
     try:
         log.info("read(%s, %s, %s)" % (path, size, offset))
         field = self.getField(path)
         if not field:
             log.info("=> ENOENT")
             return -errno.ENOENT
         if not field.hasValue():
             return ''
     except Exception, xx:
         log.info("ERR: %s" % xx)
         raise
コード例 #10
0
 def read(self, path, size, offset):
     try:
         log.info("read(%s, %s, %s)" % (path, size, offset))
         field = self.getField(path)
         if not field:
             log.info("=> ENOENT")
             return -errno.ENOENT
         if not field.hasValue():
             return ''
     except Exception, xx:
         log.info("ERR: %s" % xx)
         raise
コード例 #11
0
 def read(self, path, size, offset):
     try:
         log.info("read(%s, %s, %s)" % (path, size, offset))
         field = self.getField(path)
         if not field:
             log.info("=> ENOENT")
             return -errno.ENOENT
         if not field.hasValue():
             return ''
     except Exception as xx:
         log.info("ERR: %s" % xx)
         raise
     data = self.fieldValue(field)
     slen = len(data)
     if offset >= slen:
         return ''
     if offset + size > slen:
         size = slen - offset
     data = data[offset:offset + size]
     log.info("=> %s" % repr(data))
     return data
コード例 #12
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def truncate(self, *args):
     log.info("truncate(): TODO!")
コード例 #13
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def stop(self):
     log.info("stop()")
コード例 #14
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
 def open(self, path, flags):
     log.info("open(%s)" % path)
コード例 #15
0
 def open(self, path, flags):
     log.info("open(%s)" % path)
コード例 #16
0
ファイル: hachoir-fuse.py プロジェクト: Woerd88/hachoir
            if not field:
                log.info("=> ENOENT")
                return -errno.ENOENT
            if not field.hasValue():
                return ''
        except Exception, xx:
            log.info("ERR: %s" % xx)
            raise
        data = self.fieldValue(field)
        slen = len(data)
        if offset >= slen:
            return ''
        if offset + size > slen:
            size = slen - offset
        data = data[offset:offset+size]
        log.info("=> %s" % repr(data))
        return data

    def stop(self):
        log.info("stop()")

    def truncate(self, *args):
        log.info("truncate(): TODO!")

def main():
    usage="""
Userspace hello example

""" + Fuse.fusage
    server = HelloFS(u'/home/haypo/testcase/KDE_Click.wav',
                     version="%prog " + fuse.__version__,
コード例 #17
0
            if not field:
                log.info("=> ENOENT")
                return -errno.ENOENT
            if not field.hasValue():
                return ''
        except Exception, xx:
            log.info("ERR: %s" % xx)
            raise
        data = self.fieldValue(field)
        slen = len(data)
        if offset >= slen:
            return ''
        if offset + size > slen:
            size = slen - offset
        data = data[offset:offset + size]
        log.info("=> %s" % repr(data))
        return data

    def stop(self):
        log.info("stop()")

    def truncate(self, *args):
        log.info("truncate(): TODO!")


def main():
    usage = """
Userspace hello example

""" + Fuse.fusage
    server = HelloFS(u'/home/haypo/testcase/KDE_Click.wav',
コード例 #18
0
 def truncate(self, *args):
     log.info("truncate(): TODO!")
コード例 #19
0
 def stop(self):
     log.info("stop()")