removing boost filesystem

This commit is contained in:
Alister
2021-12-12 11:37:12 +00:00
parent b700ba70b3
commit cf6c374e81
15 changed files with 41 additions and 54 deletions

View File

@@ -24,13 +24,11 @@
#include <opengl/scoped.hpp>
#include <opengl/shader.hpp>
#include <noggit/ActionManager.hpp>
#include <external/PNG2BLP/Png2Blp.h>
#include <external/tracy/Tracy.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/pool/pool_alloc.hpp>

View File

@@ -76,19 +76,19 @@ namespace noggit::application {
{
try
{
boost::filesystem::path startupPath(argv[0]);
std::filesystem::path startupPath(argv[0]);
startupPath.remove_filename();
if (startupPath.is_relative())
{
boost::filesystem::current_path(boost::filesystem::current_path() / startupPath);
std::filesystem::current_path(std::filesystem::current_path() / startupPath);
}
else
{
boost::filesystem::current_path(startupPath);
std::filesystem::current_path(startupPath);
}
}
catch (const boost::filesystem::filesystem_error& ex)
catch (const std::filesystem::filesystem_error& ex)
{
LogError << ex.what() << std::endl;
}

View File

@@ -4,7 +4,7 @@
#define NOGGIT_APPLICATION_HPP
#include <memory>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <ClientData.hpp>
#include <noggit/ui/main_window.hpp>
#include <noggit/application/NoggitApplication.hpp>
@@ -26,7 +26,7 @@
#include <QSplashScreen>
#include <codecvt>
#include <string>
#include "revision.h"
#include <revision.h>
namespace noggit::application {
@@ -51,7 +51,7 @@ namespace noggit::application {
std::unique_ptr<noggit::ui::main_window> main_window;
std::unique_ptr<BlizzardArchive::ClientData> _client_data;
boost::filesystem::path wowpath;
std::filesystem::path wowpath;
std::string project_path;
bool fullscreen;

View File

@@ -7,7 +7,6 @@
#include <noggit/Misc.h>
#include <ClientFile.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <algorithm>

View File

@@ -445,7 +445,7 @@ void MapIndex::saveTile(const tile_index& tile, World* world, bool save_unloaded
if (save_unloaded)
{
QSettings settings;
auto filepath = boost::filesystem::path (settings.value ("project/path").toString().toStdString())
auto filepath = std::filesystem::path (settings.value ("project/path").toString().toStdString())
/ BlizzardArchive::ClientData::normalizeFilenameInternal (mTiles[tile.z][tile.x].tile->file_key().filepath());
QFile file(filepath.string().c_str());
@@ -488,7 +488,7 @@ void MapIndex::saveChanged (World* world, bool save_unloaded)
}
QSettings settings;
auto filepath = boost::filesystem::path (settings.value ("project/path").toString().toStdString())
auto filepath = std::filesystem::path (settings.value ("project/path").toString().toStdString())
/ BlizzardArchive::ClientData::normalizeFilenameInternal (mTiles[i][j].tile->file_key().filepath());
if (mTiles[i][j].flags & 0x1)

View File

@@ -1,7 +1,7 @@
//Folder to contain all of the project related files
#include <boost/filesystem/directory.hpp>
#include <noggit/Log.h>
#include <nlohmann/json.hpp>
#include <fstream>
namespace noggit::project
{
@@ -39,28 +39,28 @@ namespace noggit::project
//START - maybe handle noggit settings and paths within noggit applications?
auto currentPath = boost::filesystem::current_path();
auto currentPath = std::filesystem::current_path();
auto projectDirectoryPath = currentPath.append("/projects");
if (!boost::filesystem::exists(projectDirectoryPath))
if (!std::filesystem::exists(projectDirectoryPath))
{
LogDebug << "Creating project folder as none existed: " << projectDirectoryPath << std::endl;
boost::filesystem::create_directory(projectDirectoryPath);
std::filesystem::create_directory(projectDirectoryPath);
}
//END
auto currentProjectDirectoryPath = currentPath.append("/projects/").append(projectName);
if (!boost::filesystem::exists(currentProjectDirectoryPath))
if (!std::filesystem::exists(currentProjectDirectoryPath))
{
LogDebug << "Creating new project folder as none existed: " << currentProjectDirectoryPath << std::endl;
boost::filesystem::create_directory(currentProjectDirectoryPath);
std::filesystem::create_directory(currentProjectDirectoryPath);
}
if (boost::filesystem::is_empty(currentProjectDirectoryPath))
if (std::filesystem::is_empty(currentProjectDirectoryPath))
{
LogDebug << "Project directory is empty! Generating essential files." << std::endl;
//Create project Json
@@ -70,7 +70,7 @@ namespace noggit::project
configuration.gameClientVersion = gameClientVersion;
configuration.gameClientPath = gameClientPath;
auto fileStream = boost::filesystem::ofstream(projectPath + "/project.json");
auto fileStream = std::ofstream(projectPath + "/project.json");
fileStream << configuration.Serialise();
fileStream.close();
}

View File

@@ -9,7 +9,6 @@
#include <noggit/World.h>
#include <noggit/camera.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <noggit/Log.h>
@@ -47,16 +46,16 @@ namespace noggit
register_functions(this);
boost::filesystem::recursive_directory_iterator end;
std::filesystem::recursive_directory_iterator end;
if(!boost::filesystem::exists("scripts"))
if(!std::filesystem::exists("scripts"))
{
_tool->addLog("[error]: 'scripts' directory does not exist");
set_tool_error(_tool);
return;
}
if(!boost::filesystem::is_directory("scripts"))
if(!std::filesystem::is_directory("scripts"))
{
_tool->addLog("[error]: 'scripts' is not a directory");
set_tool_error(_tool);
@@ -66,7 +65,7 @@ namespace noggit
unsigned int error_count = 0;
unsigned int file_count = 0;
for (boost::filesystem::recursive_directory_iterator dir("scripts"); dir != end; ++dir)
for (std::filesystem::recursive_directory_iterator dir("scripts"); dir != end; ++dir)
{
std::string file = dir->path().string();
if (!boost::ends_with(file, ".lua") || boost::ends_with(file, ".spec.lua"))
@@ -163,7 +162,7 @@ namespace noggit
std::string script_context::file_to_module(std::string const& file)
{
auto rel = boost::filesystem::relative(boost::filesystem::path(file),boost::filesystem::path("scripts"))
auto rel = std::filesystem::relative(std::filesystem::path(file), std::filesystem::path("scripts"))
.string();
std::replace(rel.begin(),rel.end(),'\\','/');
return rel.substr(0,rel.size()-strlen(".lua"));
@@ -171,7 +170,7 @@ namespace noggit
std::string script_context::module_to_file(std::string const& mod)
{
return (boost::filesystem::path("scripts") / boost::filesystem::path(mod + ".lua")).string();
return (std::filesystem::path("scripts") / std::filesystem::path(mod + ".lua")).string();
}
void script_context::execute_file(std::string const& file)

View File

@@ -6,13 +6,13 @@
#include <noggit/scripting/script_context.hpp>
#include <noggit/ui/SettingsPanel.h>
#include <fstream>
#include <QtWidgets/QMessageBox>
#include <boost/filesystem.hpp>
#include <sol/sol.hpp>
#include <set>
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
namespace noggit
{
@@ -41,12 +41,12 @@ namespace noggit
}
namespace {
std::set<boost::filesystem::path> allowed_files;
std::set<std::filesystem::path> allowed_files;
}
boost::filesystem::path get_writable_path(std::string const& caller, script_context * state, std::string const& path)
std::filesystem::path get_writable_path(std::string const& caller, script_context * state, std::string const& path)
{
auto canonical = boost::filesystem::weakly_canonical(boost::filesystem::path(path));
auto canonical = std::filesystem::weakly_canonical(std::filesystem::path(path));
if (state->tool()->get_noggit_settings()->value("allow_scripts_write_any_file", false).toBool())
{
return canonical;

View File

@@ -1,8 +1,6 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#pragma once
#include <boost/filesystem.hpp>
#include <filesystem>
#include <string>
namespace noggit
@@ -11,8 +9,8 @@ namespace noggit
{
class script_context;
class scripting_tool;
namespace fs = boost::filesystem;
boost::filesystem::path get_writable_path(std::string const& caller, script_context * state, std::string const& path);
namespace fs = std::filesystem;
std::filesystem::path get_writable_path(std::string const& caller, script_context * state, std::string const& path);
void write_file(script_context * ctx, std::string const& path, std::string const& content);
void append_file(script_context * ctx, std::string const& path, std::string const& content);
std::string read_file(std::string const& path);

View File

@@ -5,7 +5,8 @@
#include <noggit/scripting/script_context.hpp>
#include <sol/sol.hpp>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
#include <iomanip>
@@ -310,7 +311,7 @@ namespace noggit
void script_settings::load_json()
{
if (!boost::filesystem::exists(SCRIPT_FILE))
if (!std::filesystem::exists(SCRIPT_FILE))
{
return;
}
@@ -321,18 +322,18 @@ namespace noggit
}
catch (std::exception err)
{
if (!boost::filesystem::exists(SCRIPT_FILE))
if (!std::filesystem::exists(SCRIPT_FILE))
{
return;
}
// back up broken script settings, since they won't be read and will be overwritten.
std::string backup_file = std::string(SCRIPT_FILE) + ".backup";
int i = 0;
while (boost::filesystem::exists(backup_file + std::to_string(i)))
while (std::filesystem::exists(backup_file + std::to_string(i)))
{
++i;
}
boost::filesystem::copy(SCRIPT_FILE, backup_file + std::to_string(i));
std::filesystem::copy(SCRIPT_FILE, backup_file + std::to_string(i));
// Add a message box here
}
}

View File

@@ -17,7 +17,6 @@
#include <QtWidgets/QPushButton>
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QCheckBox>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <cmath>

View File

@@ -25,10 +25,6 @@
#include <QtWidgets/QComboBox>
#include <QtWidgets/QVBoxLayout>
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/range/iterator_range.hpp>
namespace noggit
{
namespace ui
@@ -94,15 +90,14 @@ namespace noggit
{
QSettings settings;
auto const prefix
(boost::filesystem::path (settings.value("project/path").toString().toStdString()));
auto const prefix (std::filesystem::path (settings.value("project/path").toString().toStdString()));
auto const prefix_size (prefix.string().length());
if (boost::filesystem::exists (prefix))
if (std::filesystem::exists (prefix))
{
for ( auto const& entry_abs
: boost::make_iterator_range
(boost::filesystem::recursive_directory_iterator (prefix), {})
(std::filesystem::recursive_directory_iterator (prefix), {})
)
{
auto entry ( BlizzardArchive::ClientData::normalizeFilenameInternal

View File

@@ -125,7 +125,7 @@ namespace noggit
file.write(data);
file.close();
boost::filesystem::path pluginPath = boost::filesystem::path(lib_dir.absoluteFilePath("noggit").toStdString());
std::filesystem::path pluginPath = std::filesystem::path(lib_dir.absoluteFilePath("noggit").toStdString());
typedef boost::shared_ptr<Plugin>(PluginCreate)();
boost::function <PluginCreate> pluginCreator;

View File

@@ -9,7 +9,6 @@
#include <opengl/context.inl>
#include <opengl/shader.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <algorithm>

View File

@@ -6,7 +6,6 @@
#include <opengl/texture.hpp>
#include <noggit/Misc.h>
#include <glm/vec3.hpp>
#include <boost/filesystem/string_file.hpp>
#include <QFile>
#include <QTextStream>