sys: Bunch of cleanup, use fs::path instead of std::string for paths

This commit is contained in:
WerWolv
2022-01-16 01:51:31 +01:00
parent ed8ee35a86
commit a70ece7b9c
32 changed files with 206 additions and 292 deletions

View File

@@ -18,7 +18,7 @@ using namespace std::literals::string_literals;
namespace hex {
PyObject* LoaderScript::Py_getFilePath(PyObject *self, PyObject *args) {
return PyUnicode_FromString(LoaderScript::s_filePath.c_str());
return PyUnicode_FromString(LoaderScript::s_filePath.string().c_str());
}
PyObject* LoaderScript::Py_addPatch(PyObject *self, PyObject *args) {
@@ -178,7 +178,7 @@ namespace hex {
return createStructureType("union", args);
}
bool LoaderScript::processFile(const std::string &scriptPath) {
bool LoaderScript::processFile(const fs::path &scriptPath) {
Py_SetProgramName(Py_DecodeLocale((SharedData::mainArgv)[0], nullptr));
for (const auto &dir : hex::getPath(ImHexPath::Python)) {
@@ -220,7 +220,7 @@ namespace hex {
}
File scriptFile(scriptPath, File::Mode::Read);
PyRun_SimpleFile(scriptFile.getHandle(), scriptPath.c_str());
PyRun_SimpleFile(scriptFile.getHandle(), scriptFile.getPath().string().c_str());
Py_Finalize();