mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 15:45:33 +00:00
Replace std::filesystem::path by std::string and std::string_view in nif code
It's used only for error reporting.
This commit is contained in:
parent
cd3c3ebadb
commit
79b73e45a1
4 changed files with 17 additions and 14 deletions
|
@ -65,10 +65,10 @@ void readNIF(
|
|||
std::cout << " from '" << Files::pathToUnicodeString(isBSA(source) ? source.filename() : source) << "'";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::filesystem::path fullPath = !source.empty() ? source / path : path;
|
||||
const std::filesystem::path fullPath = !source.empty() ? source / path : path;
|
||||
try
|
||||
{
|
||||
Nif::NIFFile file(fullPath);
|
||||
Nif::NIFFile file(Files::pathToUnicodeString(fullPath));
|
||||
Nif::Reader reader(file, nullptr);
|
||||
if (vfs != nullptr)
|
||||
reader.parse(vfs->get(pathStr));
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
#ifndef OPENMW_COMPONENTS_NIF_EXCEPTION_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_EXCEPTION_HPP
|
||||
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
struct Exception : std::runtime_error
|
||||
{
|
||||
explicit Exception(const std::string& message, const std::filesystem::path& path)
|
||||
: std::runtime_error("NIFFile Error: " + message + " when reading " + Files::pathToUnicodeString(path))
|
||||
explicit Exception(std::string_view message, std::string_view path)
|
||||
: std::runtime_error([&] {
|
||||
std::string result = "NIFFile Error: ";
|
||||
result += message;
|
||||
result += " when reading ";
|
||||
result += path;
|
||||
return result;
|
||||
}())
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define OPENMW_COMPONENTS_NIF_NIFFILE_HPP
|
||||
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include <components/files/istreamptr.hpp>
|
||||
|
@ -45,7 +45,7 @@ namespace Nif
|
|||
std::uint32_t mBethVersion = 0;
|
||||
|
||||
/// File name, used for error messages and opening the file
|
||||
std::filesystem::path mPath;
|
||||
std::string mPath;
|
||||
std::string mHash;
|
||||
|
||||
/// Record list
|
||||
|
@ -56,7 +56,7 @@ namespace Nif
|
|||
|
||||
bool mUseSkinning = false;
|
||||
|
||||
explicit NIFFile(const std::filesystem::path& path)
|
||||
explicit NIFFile(std::string_view path)
|
||||
: mPath(path)
|
||||
{
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ namespace Nif
|
|||
std::size_t numRoots() const { return mFile->mRoots.size(); }
|
||||
|
||||
/// Get the name of the file
|
||||
const std::filesystem::path& getFilename() const { return mFile->mPath; }
|
||||
const std::string& getFilename() const { return mFile->mPath; }
|
||||
|
||||
const std::string& getHash() const { return mFile->mHash; }
|
||||
|
||||
|
@ -104,7 +104,7 @@ namespace Nif
|
|||
std::uint32_t& mBethVersion;
|
||||
|
||||
/// File name, used for error messages and opening the file
|
||||
std::filesystem::path& mFilename;
|
||||
std::string_view mFilename;
|
||||
std::string& mHash;
|
||||
|
||||
/// Record list
|
||||
|
@ -144,7 +144,7 @@ namespace Nif
|
|||
void setUseSkinning(bool skinning);
|
||||
|
||||
/// Get the name of the file
|
||||
std::filesystem::path getFilename() const { return mFilename; }
|
||||
std::string_view getFilename() const { return mFilename; }
|
||||
|
||||
/// Get the version of the NIF format used
|
||||
std::uint32_t getVersion() const { return mVersion; }
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace NifBullet
|
|||
if (node)
|
||||
roots.emplace_back(node);
|
||||
}
|
||||
mShape->mFileName = Files::pathToUnicodeString(nif.getFilename());
|
||||
mShape->mFileName = nif.getFilename();
|
||||
if (roots.empty())
|
||||
{
|
||||
warn("Found no root nodes in NIF file " + mShape->mFileName);
|
||||
|
|
Loading…
Reference in a new issue