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/StarDirectoryAssetSource.hpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/base/StarDirectoryAssetSource.hpp')
-rw-r--r-- | source/base/StarDirectoryAssetSource.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/base/StarDirectoryAssetSource.hpp b/source/base/StarDirectoryAssetSource.hpp new file mode 100644 index 0000000..0604132 --- /dev/null +++ b/source/base/StarDirectoryAssetSource.hpp @@ -0,0 +1,41 @@ +#ifndef STAR_DIRECTORY_ASSET_SOURCE_HPP +#define STAR_DIRECTORY_ASSET_SOURCE_HPP + +#include "StarAssetSource.hpp" +#include "StarString.hpp" + +namespace Star { + +STAR_CLASS(DirectoryAssetSource); + +class DirectoryAssetSource : public AssetSource { +public: + // Any file that forms an asset path that matches any of the patterns in + // 'ignorePatterns' is ignored. + DirectoryAssetSource(String const& baseDirectory, StringList const& ignorePatterns = {}); + + JsonObject metadata() const override; + StringList assetPaths() const override; + + IODevicePtr open(String const& path) override; + ByteArray read(String const& path) override; + + // Converts an asset path to the path on the filesystem + String toFilesystem(String const& path) const; + + // Update metadata file or add a new one. + void setMetadata(JsonObject metadata); + +private: + void scanAll(String const& assetDirectory, StringList& output) const; + + String m_baseDirectory; + List<String> m_ignorePatterns; + Maybe<String> m_metadataFile; + JsonObject m_metadata; + StringList m_assetPaths; +}; + +} + +#endif |