diff options
| author | bunnei <bunneidev@gmail.com> | 2020-08-09 17:19:34 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-09 17:19:34 -0400 |
| commit | 664019954af0a2bf31049607367bd70e05a563fe (patch) | |
| tree | ad6332cef3e3b1d796b83504459a579357c20ad7 /src/core/file_sys/vfs_vector.h | |
| parent | f14bb61acd8ec9357bc453f7cbeca800143df5dd (diff) | |
| parent | 0a5456feb9bc2a0e7f02b4b7cee34f0353e76b59 (diff) | |
Merge pull request #4488 from lioncash/file
vfs_vector: Make creation of array vfs files less verbose
Diffstat (limited to 'src/core/file_sys/vfs_vector.h')
| -rw-r--r-- | src/core/file_sys/vfs_vector.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index ac36cb2ee..95d3da2f2 100644 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h @@ -4,7 +4,11 @@ #pragma once +#include <array> #include <cstring> +#include <memory> +#include <string> +#include <vector> #include "core/file_sys/vfs.h" namespace FileSys { @@ -13,7 +17,8 @@ namespace FileSys { template <std::size_t size> class ArrayVfsFile : public VfsFile { public: - ArrayVfsFile(std::array<u8, size> data, std::string name = "", VirtualDir parent = nullptr) + explicit ArrayVfsFile(const std::array<u8, size>& data, std::string name = "", + VirtualDir parent = nullptr) : data(data), name(std::move(name)), parent(std::move(parent)) {} std::string GetName() const override { @@ -61,6 +66,12 @@ private: VirtualDir parent; }; +template <std::size_t Size, typename... Args> +std::shared_ptr<ArrayVfsFile<Size>> MakeArrayFile(const std::array<u8, Size>& data, + Args&&... args) { + return std::make_shared<ArrayVfsFile<Size>>(data, std::forward<Args>(args)...); +} + // An implementation of VfsFile that is backed by a vector optionally supplied upon construction class VectorVfsFile : public VfsFile { public: |
