sys: Tons of long overdue cleanup

- std::string -> const std::string& where needed
- Added a FileIO abstraction class
- Fixed recent files not updating
- Removed localization file from global include
- Renamed lang to pattern_language/pl
- Renamed EventFileDropped to RequestFileOpen
This commit is contained in:
WerWolv
2021-09-08 15:18:24 +02:00
parent d7707bae62
commit e74c0f5cf5
74 changed files with 549 additions and 494 deletions

View File

@@ -2,6 +2,7 @@
#include <hex/helpers/utils.hpp>
#include <hex/helpers/paths.hpp>
#include <hex/helpers/file.hpp>
#include <hex/views/view.hpp>
#include <hex/providers/provider.hpp>
@@ -177,7 +178,7 @@ namespace hex {
return createStructureType("union", args);
}
bool LoaderScript::processFile(std::string_view scriptPath) {
bool LoaderScript::processFile(const std::string &scriptPath) {
Py_SetProgramName(Py_DecodeLocale((SharedData::mainArgv)[0], nullptr));
for (const auto &dir : hex::getPath(ImHexPath::Python)) {
@@ -218,10 +219,8 @@ namespace hex {
PyList_Insert(sysPath, 0, path);
}
FILE *scriptFile = fopen(scriptPath.data(), "r");
PyRun_SimpleFile(scriptFile, scriptPath.data());
fclose(scriptFile);
File scriptFile(scriptPath, File::Mode::Read);
PyRun_SimpleFile(scriptFile.getHandle(), scriptPath.c_str());
Py_Finalize();