Fixed other functions in RelativeFileSystemAdapter.
This commit is contained in:
parent
3b7396c4d6
commit
83a46cae15
@ -42,6 +42,8 @@ public:
|
||||
std::vector<FileInfo> listFiles(const fs::path& folder) override;
|
||||
FileInfo getFileInfo(const fs::path& file) override;
|
||||
StreamError open(const fs::path& path, FileOpenMode mode, std::unique_ptr<Stream>& outStream) override;
|
||||
private:
|
||||
fs::path appendPath(const fs::path& other) const noexcept;
|
||||
};
|
||||
|
||||
//
|
||||
@ -64,15 +66,8 @@ template<typename TWrapped>
|
||||
std::vector<FileInfo> RelativeFileSystemAdapter<TWrapped>::listFiles(const fs::path& folder)
|
||||
{
|
||||
std::vector<FileInfo> result;
|
||||
fs::path combinedPath = root_;
|
||||
if (folder.is_absolute()) {
|
||||
combinedPath += folder;
|
||||
}
|
||||
else {
|
||||
combinedPath /= folder;
|
||||
}
|
||||
|
||||
result = wrapped_.listFiles(combinedPath);
|
||||
result = wrapped_.listFiles(appendPath(folder));
|
||||
for (FileInfo& fileInfo : result) {
|
||||
fileInfo.path = "/" / fileInfo.path.lexically_relative(root_);
|
||||
}
|
||||
@ -82,15 +77,27 @@ std::vector<FileInfo> RelativeFileSystemAdapter<TWrapped>::listFiles(const fs::p
|
||||
template<typename TWrapped>
|
||||
FileInfo RelativeFileSystemAdapter<TWrapped>::getFileInfo(const fs::path& file)
|
||||
{
|
||||
return wrapped_.getFileInfo(root_ / file);
|
||||
return wrapped_.getFileInfo(appendPath(file));
|
||||
}
|
||||
|
||||
template<typename TWrapped>
|
||||
StreamError RelativeFileSystemAdapter<TWrapped>::open(const fs::path& path, FileOpenMode mode, std::unique_ptr<Stream>& outStream)
|
||||
{
|
||||
return wrapped_.open(root_ / path, mode, outStream);
|
||||
return wrapped_.open(appendPath(path), mode, outStream);
|
||||
}
|
||||
|
||||
template<typename TWrapped>
|
||||
fs::path RelativeFileSystemAdapter<TWrapped>::appendPath(const fs::path& other) const noexcept
|
||||
{
|
||||
fs::path combinedPath = root_;
|
||||
if (other.is_absolute()) {
|
||||
combinedPath += other;
|
||||
}
|
||||
else {
|
||||
combinedPath /= other;
|
||||
}
|
||||
return combinedPath;
|
||||
}
|
||||
} // namespace mijin
|
||||
|
||||
#endif // !defined(MIJIN_VIRTUAL_FILESYSTEM_RELATIVE_HPP_INCLUDED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user