feature add filesystem
Some checks failed
build-crpc / build (Debug, mingw-w64-xi686.toolchain.cmake) (push) Waiting to run
build-crpc / build (Release, mingw-w64-x86_64.toolchain.cmake) (push) Waiting to run
build-crpc / build (Release, mingw-w64-xi686.toolchain.cmake) (push) Waiting to run
build-crpc / build (Debug, host.toolchain.cmake) (push) Failing after 2m4s
build-crpc / build (Debug, mingw-w64-x86_64.toolchain.cmake) (push) Failing after 1m53s
build-crpc / build (Release, host.toolchain.cmake) (push) Has been cancelled

This commit is contained in:
tqcq 2023-12-03 12:42:44 +08:00
parent f0175170ec
commit 957fd68868
4 changed files with 24 additions and 19 deletions

View File

@ -6,6 +6,7 @@
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <filesystem>
namespace tqcq { namespace tqcq {

View File

@ -3,27 +3,31 @@
// //
#include "plugin.h" #include "plugin.h"
#include <sys/stat.h> #include <filesystem>
namespace tqcq { namespace tqcq {
static void EnsureDirectoryExist(std::string path) static void EnsureDirectoryExist(std::string path)
{ {
std::string::size_type pos = 0; std::string::size_type pos = 0;
bool is_end = false; // create path recursively
while (!is_end) { std::filesystem::path p(path);
pos = path.find('/', pos); if (!std::filesystem::exists(p.parent_path())) { std::filesystem::create_directories(p.parent_path()); }
if (pos == std::string::npos) {
is_end = true; // bool is_end = false;
} // while (!is_end) {
std::string dir = path.substr(0, pos); // pos = path.find('/', pos);
int status = mkdir(dir.c_str(), 0755); // if (pos == std::string::npos) {
if (status != 0 && errno != EEXIST) { // is_end = true;
perror("mkdir"); // }
exit(1); // std::string dir = path.substr(0, pos);
} // int status = mkdir(dir.c_str(), 0755);
pos++; // if (status != 0 && errno != EEXIST) {
} // perror("mkdir");
// exit(1);
// }
// pos++;
// }
} }
Plugin::Plugin(std::string generate_path, std::string generate_prefix) Plugin::Plugin(std::string generate_path, std::string generate_prefix)

View File

@ -3,8 +3,8 @@ set(TOOLCHAIN_PREFIX i686-w64-mingw32)
set(CMAKE_CROSSCOMPILING TRUE) set(CMAKE_CROSSCOMPILING TRUE)
# cross compilers to use for C, C++ and Fortran # cross compilers to use for C, C++ and Fortran
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)

View File

@ -3,8 +3,8 @@ set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
set(CMAKE_CROSSCOMPILING TRUE) set(CMAKE_CROSSCOMPILING TRUE)
# cross compilers to use for C, C++ and Fortran # cross compilers to use for C, C++ and Fortran
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)