1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 09:39:43 +00:00

Remove boost::filesystem from bsatool

This commit is contained in:
jvoisin 2022-05-22 18:52:05 +02:00
parent 8dd3e53a30
commit fb732d74a2
2 changed files with 15 additions and 18 deletions

View file

@ -1,10 +1,10 @@
#include <filesystem>
#include <fstream>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <vector> #include <vector>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <components/bsa/compressedbsafile.hpp> #include <components/bsa/compressedbsafile.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
@ -13,7 +13,6 @@
// Create local aliases for brevity // Create local aliases for brevity
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
namespace bfs = boost::filesystem;
struct Arguments struct Arguments
{ {
@ -201,26 +200,26 @@ int extract(std::unique_ptr<File>& bsa, Arguments& info)
} }
// Get the target path (the path the file will be extracted to) // Get the target path (the path the file will be extracted to)
bfs::path relPath (extractPath); std::filesystem::path relPath (extractPath);
bfs::path outdir (info.outdir); std::filesystem::path outdir (info.outdir);
bfs::path target; std::filesystem::path target;
if (info.fullpath) if (info.fullpath)
target = outdir / relPath; target = outdir / relPath;
else else
target = outdir / relPath.filename(); target = outdir / relPath.filename();
// Create the directory hierarchy // Create the directory hierarchy
bfs::create_directories(target.parent_path()); std::filesystem::create_directories(target.parent_path());
bfs::file_status s = bfs::status(target.parent_path()); std::filesystem::file_status s = std::filesystem::status(target.parent_path());
if (!bfs::is_directory(s)) if (!std::filesystem::is_directory(s))
{ {
std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl; std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl;
return 3; return 3;
} }
bfs::ofstream out(target, std::ios::binary); std::ofstream out(target, std::ios::binary);
// Write the file to disk // Write the file to disk
std::cout << "Extracting " << info.extractfile << " to " << target << std::endl; std::cout << "Extracting " << info.extractfile << " to " << target << std::endl;
@ -240,14 +239,14 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
Misc::StringUtils::replaceAll(extractPath, "\\", "/"); Misc::StringUtils::replaceAll(extractPath, "\\", "/");
// Get the target path (the path the file will be extracted to) // Get the target path (the path the file will be extracted to)
bfs::path target (info.outdir); std::filesystem::path target (info.outdir);
target /= extractPath; target /= extractPath;
// Create the directory hierarchy // Create the directory hierarchy
bfs::create_directories(target.parent_path()); std::filesystem::create_directories(target.parent_path());
bfs::file_status s = bfs::status(target.parent_path()); std::filesystem::file_status s = std::filesystem::status(target.parent_path());
if (!bfs::is_directory(s)) if (!std::filesystem::is_directory(s))
{ {
std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl; std::cout << "ERROR: " << target.parent_path() << " is not a directory." << std::endl;
return 3; return 3;
@ -255,7 +254,7 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
// Get a stream for the file to extract // Get a stream for the file to extract
Files::IStreamPtr data = bsa->getFile(&file); Files::IStreamPtr data = bsa->getFile(&file);
bfs::ofstream out(target, std::ios::binary); std::ofstream out(target, std::ios::binary);
// Write the file to disk // Write the file to disk
std::cout << "Extracting " << target << std::endl; std::cout << "Extracting " << target << std::endl;
@ -269,7 +268,7 @@ int extractAll(std::unique_ptr<File>& bsa, Arguments& info)
template<typename File> template<typename File>
int add(std::unique_ptr<File>& bsa, Arguments& info) int add(std::unique_ptr<File>& bsa, Arguments& info)
{ {
boost::filesystem::fstream stream(info.addfile, std::ios_base::binary | std::ios_base::out | std::ios_base::in); std::fstream stream(info.addfile, std::ios_base::binary | std::ios_base::out | std::ios_base::in);
bsa->addFile(info.addfile, stream); bsa->addFile(info.addfile, stream);
return 0; return 0;

View file

@ -4,8 +4,6 @@
#include <limits> #include <limits>
#include <list> #include <list>
#include <boost/concept_check.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>