4 #include <QJsonDocument>
8 #include <QMimeDatabase>
10 #include <QFileSystemWatcher>
21 explicit VFS_HD_cache_entry(QString
path,
bool debug,
int flushInterval,
int expireInterval,
bool create=
false,
bool container=
false,
bool raw=
false,
bool watch=
false);
24 virtual bool valid(QString &reason);
75 virtual QByteArray
icon();
A subclass of VFS_datastore_cache_entry, used for disk access.
virtual void flush()
Actually write the file to disk.
QString _path
The actual file path.
QFileSystemWatcher _watcher
Watches for changes to the file or directory, and expires the entry on change.
QFileInfo _info
An info object, useful for type and metadata information.
virtual ~VFS_HD_cache_entry()
VFS_HD_cache_entry destructor.
VFS_HD_cache_entry(QString path, bool debug, int flushInterval, int expireInterval, bool create=false, bool container=false, bool raw=false, bool watch=false)
void modified(const QString &path)
A slot for when the _watcher detects that there has been a change.
virtual bool valid(QString &reason)
If the file or directory does not exist or is not readable, _valid is set to false.
A VFS_datastore subclass for storing data on a locally attached hard drive or NFS share.
const QString path()
Return the _path of this node.
bool _raw
Whether to default to JSON mode or RAW mode, which can be overridden with metadata.
virtual QByteArray icon()
The "disk" icon found in the VFS_icons library.
virtual void applyDiff(VFS_request *r)
Apply a diff to a file.
virtual QString reportDetails()
Report the current cache usage.
virtual void rm(VFS_request *r)
Attempt to delete a file.
virtual void read(VFS_request *r)
Read the contents of a directory or file.
virtual void fetchRange(VFS_request *r)
Fetch a byte range within a file.
Q_INVOKABLE VFS_HD(QString p, quint64 size=VFS_datastore_cache::DEFAULT_DATACACHE_SIZE, bool create=false, bool debug=false, int flushInterval=5000, int expireInterval=60000, bool raw=false, bool watch=false)
Create a VFS_HD node, with an optional create flag.
int _expireInterval
Interval for cache entries to expire, in milliseconds.
virtual void write(VFS_request *r)
Write data to a file.
static QMimeDatabase _mimeDatabase
The mime database, used for metadata.
bool _watch
Whether to set the watch flag on cache entries.
virtual void submit(VFS_request *r)
Submit data to a file, applying the data as a diff.
QString _path
The base prefix path for this VFS_HD node.
virtual void ls(VFS_request *r)
List the contents of a filesystem directory.
virtual void subscribe(VFS_request *r)
Subscribe to changes on a file or directory.
int _flushInterval
Interval for cache entries to flush, in milliseconds.
virtual void metadata(VFS_request *r)
Fetch the metadata for a file or directory.
A pure virtual class which must be subclassed for data storage.
static const quint64 DEFAULT_DATACACHE_SIZE
The default size to create a cache. Defaults to 100mb.
A base class for creating storage nodes in VFS.
The base class for all requests between nodes.