Start to create structure

parent d19ce371
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function, absolute_import, division
import logging
......@@ -10,14 +10,32 @@ from threading import Lock
from fusepy import FUSE, FuseOSError, Operations, LoggingMixIn
class Loopback(LoggingMixIn, Operations):
def __init__(self, root):
self.root = realpath(root)
self.rwlock = Lock()
#def __call__(self, op, path, *args):
# return super(Loopback, self).__call__(op, self.root + path, *args)
def __call__(self, op, path, *args):
print(op)
print(path)
if path=='/' and op!='init':
return super(Loopback, self).__call__('base_'+op, path, *args)
if path=='/' and op=='init':
return super(Loopback, self).__call__(op, path, *args)
psplit=path.split('/', 2)
pstart=False
if len(psplit)>1:
pstart=psplit[1]
if pstart and pstart=='CONTENT':
return super(Loopback, self).__call__(op, self.root + path.replace('/CONTENT', ''), *args)
if pstart in ['TAGS', 'CATEGORIES'] and path.replace('/'+pstart, '') == '':
return super(Loopback, self).__call__(op, self.root, *args)
raise FuseOSError(EACCES)
def base_destroy(self,*args):
return self.destroy(*args)
def access(self, path, mode):
if not os.access(path, mode):
......@@ -44,6 +62,15 @@ class Loopback(LoggingMixIn, Operations):
'st_atime', 'st_ctime', 'st_gid', 'st_mode', 'st_mtime',
'st_nlink', 'st_size', 'st_uid'))
def base_getattr(self, path, fh=None):
return {'st_atime': 1692365924.6988926, 'st_ctime': 1692365924.6988926, 'st_gid': 1000, 'st_mode': 16877, 'st_mtime': 1692365924.6988926, 'st_nlink': 2, 'st_size': 0, 'st_uid': 1000}
def base_opendir(self, path, fh=None):
return 0
def base_releasedir(self, path, fh=None):
return 0
getxattr = None
def link(self, target, source):
......@@ -62,6 +89,9 @@ class Loopback(LoggingMixIn, Operations):
def readdir(self, path, fh):
return ['.', '..'] + os.listdir(path)
def base_readdir(self, path, fh):
return ['.', '..', 'CONTENT', 'TAGS', 'CATEGORIES']
readlink = os.readlink
def release(self, path, fh):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment