diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/base/StarPackedAssetSource.hpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/base/StarPackedAssetSource.hpp')
-rw-r--r-- | source/base/StarPackedAssetSource.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/base/StarPackedAssetSource.hpp b/source/base/StarPackedAssetSource.hpp new file mode 100644 index 0000000..eae5069 --- /dev/null +++ b/source/base/StarPackedAssetSource.hpp @@ -0,0 +1,45 @@ +#ifndef STAR_PACKED_ASSET_SOURCE_HPP +#define STAR_PACKED_ASSET_SOURCE_HPP + +#include "StarOrderedMap.hpp" +#include "StarFile.hpp" +#include "StarDirectoryAssetSource.hpp" + +namespace Star { + +STAR_CLASS(PackedAssetSource); + +class PackedAssetSource : public AssetSource { +public: + typedef function<void(size_t, size_t, String, String)> BuildProgressCallback; + + // Build a packed asset file from the given DirectoryAssetSource. + // + // 'extensionSorting' sorts the packed file with file extensions that case + // insensitive match the given extensions in the order they are given. If a + // file has an extension that doesn't match any in this list, it goes after + // all other files. All files are sorted secondarily by case insensitive + // alphabetical order. + // + // If given, 'progressCallback' will be called with the total number of + // files, the current file number, the file name, and the asset path. + static void build(DirectoryAssetSource& directorySource, String const& targetPackedFile, + StringList const& extensionSorting = {}, BuildProgressCallback progressCallback = {}); + + PackedAssetSource(String const& packedFileName); + + JsonObject metadata() const override; + StringList assetPaths() const override; + + IODevicePtr open(String const& path) override; + ByteArray read(String const& path) override; + +private: + FilePtr m_packedFile; + JsonObject m_metadata; + OrderedHashMap<String, pair<uint64_t, uint64_t>> m_index; +}; + +} + +#endif |