12 #ifndef hifi_AssetUtils_h
13 #define hifi_AssetUtils_h
19 #include <QtCore/QByteArray>
20 #include <QtCore/QUrl>
22 namespace AssetUtils {
24 using DataOffset = int64_t;
26 using AssetPath = QString;
27 using AssetHash = QString;
28 using AssetPathList = QStringList;
30 const size_t SHA256_HASH_LENGTH = 32;
31 const size_t SHA256_HASH_HEX_LENGTH = 64;
32 const uint64_t MAX_UPLOAD_SIZE = 1000 * 1000 * 1000;
34 const QString ASSET_FILE_PATH_REGEX_STRING =
"^(\\/[^\\/\\0]+)+$";
35 const QString ASSET_PATH_REGEX_STRING =
"^\\/([^\\/\\0]+(\\/)?)+$";
36 const QString ASSET_HASH_REGEX_STRING = QString(
"^[a-fA-F0-9]{%1}$").arg(SHA256_HASH_HEX_LENGTH);
38 const QString HIDDEN_BAKED_CONTENT_FOLDER =
"/.baked/";
40 enum AssetServerError : uint8_t {
46 MappingOperationFailed,
52 enum AssetMappingOperationType : uint8_t {
76 using AssetMappings = std::map<AssetPath, MappingInfo>;
77 using Mappings = std::map<AssetPath, AssetHash>;
79 QUrl getATPUrl(
const QString& input);
80 AssetHash extractAssetHash(
const QString& input);
82 QByteArray hashData(
const QByteArray& data);
84 QByteArray loadFromCache(
const QUrl& url);
85 bool saveToCache(
const QUrl& url,
const QByteArray& file);
87 bool isValidFilePath(
const AssetPath& path);
88 bool isValidPath(
const AssetPath& path);
89 bool isValidHash(
const QString& hashString);
91 QString bakingStatusToString(BakingStatus status);