diff --git a/source/mijin/virtual_filesystem/filesystem.hpp b/source/mijin/virtual_filesystem/filesystem.hpp index b0c7122..bd1322c 100644 --- a/source/mijin/virtual_filesystem/filesystem.hpp +++ b/source/mijin/virtual_filesystem/filesystem.hpp @@ -35,6 +35,7 @@ namespace mijin struct FileInfo { fs::path path; + /// either file size in bytes, or number of entries if folder std::size_t size = 0; bool exists : 1 = false; bool isFolder : 1 = false; @@ -79,7 +80,8 @@ class FileSystemAdapter public: virtual ~FileSystemAdapter() = default; - [[nodiscard]] virtual fs::path getHomeFolder() = 0; + [[deprecated("Will be removed ASAP")]] + [[nodiscard]] virtual fs::path getHomeFolder() { return {}; } // TODO: get rid of this ... [[nodiscard]] virtual std::vector listFiles(const fs::path& folder) = 0; [[nodiscard]] virtual FileInfo getFileInfo(const fs::path& file) = 0; [[nodiscard]] virtual Optional getNativePath(const fs::path& /* file */) { return NULL_OPTIONAL; } diff --git a/source/mijin/virtual_filesystem/stacked.cpp b/source/mijin/virtual_filesystem/stacked.cpp index e42151d..2c2eae8 100644 --- a/source/mijin/virtual_filesystem/stacked.cpp +++ b/source/mijin/virtual_filesystem/stacked.cpp @@ -2,6 +2,7 @@ #include "./stacked.hpp" #include +#include "../detect.hpp" namespace mijin { @@ -35,7 +36,14 @@ fs::path StackedFileSystemAdapter::getHomeFolder() if (adapters_.empty()) { return fs::path(); } +#if MIJIN_COMPILER == MIJIN_COMPILER_MSVC +#pragma warning(push) +#pragma warning(disable : 4996) // yeah, we're using a deprecated function here, in order to implement another deprecated function ¯\_(ツ)_/¯ +#endif return adapters_.front()->getHomeFolder(); +#if MIJIN_COMPILER == MIJIN_COMPILER_MSVC +#pragma warning(pop) +#endif } std::vector StackedFileSystemAdapter::listFiles(const fs::path& folder) diff --git a/source/mijin/virtual_filesystem/stacked.hpp b/source/mijin/virtual_filesystem/stacked.hpp index 1030ea9..70038bf 100644 --- a/source/mijin/virtual_filesystem/stacked.hpp +++ b/source/mijin/virtual_filesystem/stacked.hpp @@ -36,12 +36,13 @@ public: void getAllPaths(const fs::path &path, std::vector &outPaths) override; using FileSystemAdapter::getAllPaths; - inline void addAdapter(std::unique_ptr&& adapter) { + inline FileSystemAdapter* addAdapter(std::unique_ptr&& adapter) { adapters_.push_back(std::move(adapter)); + return adapters_.back().get(); } template - inline void emplaceAdapter(TArgs&&... args) { - addAdapter(std::make_unique(std::forward(args)...)); + inline TAdapter* emplaceAdapter(TArgs&&... args) { + return static_cast(addAdapter(std::make_unique(std::forward(args)...))); } };