A subclass of VFS_datastore_cache_entry, used for disk access.
More...
#include <VFS_hd.h>
|
| VFS_HD_cache_entry (QString path, bool debug, int flushInterval, int expireInterval, bool create=false, bool container=false, bool raw=false, bool watch=false) |
|
virtual | ~VFS_HD_cache_entry () |
| VFS_HD_cache_entry destructor. More...
|
|
virtual bool | valid (QString &reason) |
| If the file or directory does not exist or is not readable, _valid is set to false. More...
|
|
| VFS_datastore_cache_entry (bool debug, int flushInterval, int expireInterval, bool raw=false) |
| Construct the cache entry. More...
|
|
virtual | ~VFS_datastore_cache_entry () |
| Destroy the cache entry. More...
|
|
virtual QJsonDocument | getData () |
| Return the data from an entry. More...
|
|
virtual QByteArray | getRawData () |
| Return the data from an entry. More...
|
|
virtual void | setData (QByteArray data) |
| Write raw data to the entry. More...
|
|
virtual void | setData (QJsonObject json) |
| Write data to the entry. More...
|
|
quint64 | size () |
|
|
virtual void | flush () |
| Actually write the file to disk. More...
|
|
virtual void | touch () |
| Reset the expiration timer. More...
|
|
|
void | modified (const QString &path) |
| A slot for when the _watcher detects that there has been a change. More...
|
|
A subclass of VFS_datastore_cache_entry, used for disk access.
- See also
- VFS_datastore_cache_entry
Definition at line 14 of file VFS_hd.h.
◆ VFS_HD_cache_entry()
VFS_HD_cache_entry::VFS_HD_cache_entry |
( |
QString |
path, |
|
|
bool |
debug, |
|
|
int |
flushInterval, |
|
|
int |
expireInterval, |
|
|
bool |
create = false , |
|
|
bool |
container = false , |
|
|
bool |
raw = false , |
|
|
bool |
watch = false |
|
) |
| |
|
explicit |
- Parameters
-
path | The filesystem path of the file resource, which may be relative to the VFS executable or absolute |
debug | Verbose debug mode |
flushInterval | Interval to flush to disk, in milliseconds. |
expireInterval | Interval to expire the cache entry, in milliseconds. |
create | If the filesystem path doesn't exist and it's not a container, create an empty json object: {} . |
container | When true, and create is true, create an empty directory instead |
raw | Set the raw flag on this entry. |
watch | Set the watch flag on this entry, which will expire an entry if a change happens outside of the VFS |
- Warning
- DOCME: describe the logic here more thoroughly
Definition at line 112 of file VFS_hd.cpp.
◆ ~VFS_HD_cache_entry()
VFS_HD_cache_entry::~VFS_HD_cache_entry |
( |
| ) |
|
|
virtual |
◆ flush()
void VFS_HD_cache_entry::flush |
( |
| ) |
|
|
protectedvirtual |
Actually write the file to disk.
If the entry is not _dirty, this immediately returns. If data cannot be written to disk, the entry is left _dirty and a _reason is recorded.
If a partial file is written, a VFS::CRITICAL() message is sent, on suspicion that the disk is full.
On write success, _dirty is set to false, and the _size of the entry is updated.
- Note
- FIXME: The data size consumed in the cache should also be updated, but this is currently unimplemented.
Implements VFS_datastore_cache_entry.
Definition at line 354 of file VFS_hd.cpp.
◆ modified
void VFS_HD_cache_entry::modified |
( |
const QString & |
path | ) |
|
|
privateslot |
A slot for when the _watcher detects that there has been a change.
- Parameters
-
path | The changed path, which should be this path |
This will emit expired() to remove this entry, as it needs to be re-cached.
- Note
- On a watched cache entry, flush() will cause the _watcher to see a change and will un-cache the entry. Have to think of a solution for this.
Definition at line 307 of file VFS_hd.cpp.
◆ valid()
bool VFS_HD_cache_entry::valid |
( |
QString & |
reason | ) |
|
|
virtual |
If the file or directory does not exist or is not readable, _valid is set to false.
- Parameters
-
reason | If invalid, the reason will be written to this string. |
- Returns
- The _valid flag value
This uses values in VFS_HD_cache_entry::_info. An attempt is made to not continuously hit the disk by checking if _valid is already true, however in a production environment this optimization may be invalid.
Reimplemented from VFS_datastore_cache_entry.
Definition at line 326 of file VFS_hd.cpp.
◆ VFS_HD
◆ _info
QFileInfo VFS_HD_cache_entry::_info |
|
protected |
An info object, useful for type and metadata information.
Definition at line 28 of file VFS_hd.h.
◆ _path
QString VFS_HD_cache_entry::_path |
|
protected |
The actual file path.
Definition at line 27 of file VFS_hd.h.
◆ _watcher
QFileSystemWatcher VFS_HD_cache_entry::_watcher |
|
protected |
Watches for changes to the file or directory, and expires the entry on change.
Definition at line 29 of file VFS_hd.h.
The documentation for this class was generated from the following files: