Remoto - VFS
|
Utility functions for VFS operations. More...
Functions | |
QString | cleanPath (QString path) |
Clean and normalize a VFS path. More... | |
QJsonObject | decodeBase64Path (QByteArray p, bool *ok) |
Decode a base64 string as a JSON object. More... | |
QByteArray | encodeBase64Path (QJsonObject p) |
Encode a JSON object as a base64 string. More... | |
QStringList | exec (QString command, bool *ok=nullptr) |
execute a command in a shell, and return the resulting output as a QStringList More... | |
QStringList | expandSequence (QString sequence) |
Expand a sequence-notated list into a list of numbers. More... | |
QStringList | expandSequenceListing (QString sequence) |
Expand a sequence-notated string into a list of names. More... | |
QJsonObject | jsonResource (QString resource, bool *ok=nullptr) |
Fetch the contents of a Qt resource as a QJsonObject. More... | |
QJsonValue | parseSequenceSyntax (QString path) |
Check if a path or string matches our syntax for file sequences. More... | |
QByteArray | resourceContents (QString resource, bool *ok=nullptr, bool squashHash=false) |
Fetch the contents of a Qt resource file. More... | |
QJsonObject | sequenceListing (QJsonObject l, QStringList types=sequenceTypes) |
Given a list of filenames and a regex list, collapse the listing to sequences when possible. More... | |
QString | unescapeXMLAttribute (QString attribute) |
Un-escape an XML attribute. More... | |
Variables | |
QStringList | sequenceTypes = QStringList() << "jpe?g" << "tif?f" << "exr" << "png" << "dpx" |
A list of regular expressions which can represent image or file sequences. More... | |
Utility functions for VFS operations.
QString rutils::cleanPath | ( | QString | path | ) |
Clean and normalize a VFS path.
path | A VFS path to be cleaned and normalized |
Ostensibly, this removes leading and duplicate slashes from a path. When doing path manipulation, many times one is adding path parts together, and it can be unclear if one path part starts or ends with a slash, resulting in an unclean result.
Note that all paths are effectively resource IDs, which often must exactly match their use in other contexts.
It is recommended to use rutils::cleanPath() on all assembled paths, especially those being sent or received from a remote client.
Definition at line 32 of file rutils.cpp.
QJsonObject rutils::decodeBase64Path | ( | QByteArray | p, |
bool * | ok | ||
) |
Decode a base64 string as a JSON object.
p | The base 64 string to decode |
ok | Whether or not decode was possible |
Because Qt uses RFC 2045, we replace the '/' character with an '_', because we want to use the base64 encoded string as a path fragment.
Definition at line 613 of file rutils.cpp.
QByteArray rutils::encodeBase64Path | ( | QJsonObject | p | ) |
Encode a JSON object as a base64 string.
p | The JSON object to encode |
Because Qt uses RFC 2045, we replace the '/' character with an '_', because we want to use the base64 encoded string as a path fragment.
Definition at line 592 of file rutils.cpp.
QStringList rutils::exec | ( | QString | command, |
bool * | ok = nullptr |
||
) |
execute a command in a shell, and return the resulting output as a QStringList
command | The command to execute |
ok | A pointer to return execution status |
Definition at line 658 of file rutils.cpp.
QStringList rutils::expandSequence | ( | QString | sequence | ) |
Expand a sequence-notated list into a list of numbers.
sequence | The sequence |
Definition at line 407 of file rutils.cpp.
QStringList rutils::expandSequenceListing | ( | QString | sequence | ) |
Expand a sequence-notated string into a list of names.
sequence | The list of names |
Definition at line 499 of file rutils.cpp.
QJsonObject rutils::jsonResource | ( | QString | resource, |
bool * | ok = nullptr |
||
) |
Fetch the contents of a Qt resource as a QJsonObject.
resource | The resource path, which must start with ':' |
ok | The status of the request and parse |
Often, JSON files are stored in a resource file. This function will return parsed JSON data as a convenience for future manipulation or templatizing.
Definition at line 90 of file rutils.cpp.
QJsonValue rutils::parseSequenceSyntax | ( | QString | p | ) |
Check if a path or string matches our syntax for file sequences.
p | The path or string to check |
Definition at line 132 of file rutils.cpp.
QByteArray rutils::resourceContents | ( | QString | resource, |
bool * | ok = nullptr , |
||
bool | squashHash = false |
||
) |
Fetch the contents of a Qt resource file.
resource | The resource path, which must start with ':' |
ok | The status of the request |
squashHash | Boolean for replacing '#' with "%23" |
This is useful in plugins, for instance, where resources are stored in the plugin binary and a single line of code saves lots of time and error-checking.
If squashHash=true
, '#' will be replaced with "%23". This provides inline data URIs that contain HTML colors (like SVG files) to be compatible with Firefox and other browsers that may interpret the hash as a fragment separator.
Definition at line 53 of file rutils.cpp.
QJsonObject rutils::sequenceListing | ( | QJsonObject | l, |
QStringList | types = sequenceTypes |
||
) |
Given a list of filenames and a regex list, collapse the listing to sequences when possible.
l | The name list |
types | The regex list |
Given a list of filenames:
This function will collapse them into sequence notation:
Definition at line 183 of file rutils.cpp.
QString rutils::unescapeXMLAttribute | ( | QString | attribute | ) |
Un-escape an XML attribute.
attribute | The attribute value to un-escape |
This is used when, for instance, when inline SVG is used as an attribute value in a config file.
Currently this will replace "<"
with "<"
and ">"
with ">"
.
Definition at line 640 of file rutils.cpp.
|
extern |
A list of regular expressions which can represent image or file sequences.
When performing a rutils::sequenceListing(), these regex types can be used to identify images.
By default: jpg, jpeg, tif, tiff, exr, png, and dpx are recognized.
Definition at line 124 of file rutils.cpp.