Using C++17 filesystem directories

+ Print processing to time to log
This commit is contained in:
JackCarterSmith 2023-02-03 17:35:28 +01:00
parent 05b3c1e88a
commit 7181d65a6e
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24

View File

@ -7,8 +7,13 @@
*
*/
#if __cplusplus < 201703L
#error "This code run on C++17 or upper."
#endif
#include <iostream>
#include <fstream>
#include <chrono>
#include <string>
#include <algorithm>
#include <stdexcept>
@ -17,13 +22,12 @@
#include <deque>
#include <thread>
#endif
#include <filesystem>
#include <boost/filesystem.hpp>
#include <RDI.hpp>
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/stat.h>
#endif
using namespace boost::filesystem;
@ -210,26 +214,18 @@ static void ProcessModels() {
// Launch threaded OBJ file building
//GenerateModelOBJThreaded();
//PrintModel(meshCollection.back());
#ifdef _WIN32
CreateDirectory(".\\objOut", NULL);
#else
mkdir("./objOut");
#endif
for ( RDI::HOB* hobFile : modelCollection ) {
if (hobFile->getObjectCount()) {
string parentPath = path(hobFile->getFullPath()).parent_path().filename().string();
if (hobFile->isLoaded() && hobFile->getObjectCount()) {
string parentPath = path(hobFile->getFullPath()).string();
replace(parentPath.begin(), parentPath.end(), '/', '\\');
#ifdef _WIN32
CreateDirectory((".\\objOut\\" + parentPath).c_str(), NULL);
#else
mkdir(("./objOut/" + parentPath).c_str());
#endif
filesystem::create_directories(".\\objOut\\" + hobFile->getFullPath());
for ( i = 0; i < hobFile->getObjectCount(); i++ ) {
cout << " Processing " << hobFile->getFullPath() << "..." << endl;
cout << hobFile->getFullPath() << "/" << *(hobFile->getObjectName(i)) << "...";
GenerateModelOBJ(hobFile->getMeshFromObject(i), parentPath, hobFile->getObjectName(i));
cout << " OK" << endl;
}
}
}
@ -288,12 +284,18 @@ int main( int argc, char *argv[] ) {
for ( std::string lname : RDI::RDI_getLevelsName() ) {
cout << " " << lname << endl;
}
cout << endl << "> Models found: " << RDI::RDI_getModelsName().size() << endl;
auto t_start = chrono::high_resolution_clock::now();
ProcessModels();
auto t_end = chrono::high_resolution_clock::now();
cout << "Models processing in " << chrono::duration_cast<chrono::seconds>(t_end - t_start).count() << "s" << endl;
cout << endl << "> Textures found: " << RDI::RDI_getTexturesName().size() << endl;
for ( std::string txname : RDI::RDI_getTexturesName() ) {
cout << " " << txname << endl;
}
cout << endl << "> Musics found: " << RDI::RDI_getMusicsName().size() << endl;
for ( std::string mname : RDI::RDI_getMusicsName() ) {
cout << " " << mname << endl;