From 39978f905f7a6084e123ac92a3be2748b11699d1 Mon Sep 17 00:00:00 2001 From: Michel Juillard <michel.juillard@mjui.fr> Date: Wed, 13 May 2015 17:11:39 +0200 Subject: [PATCH] changing code for making directory baseline in order to comply with mingw --- DynamicModel.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/DynamicModel.cc b/DynamicModel.cc index b7eb27d8..339cbe97 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -4289,24 +4289,29 @@ DynamicModel::isChecksumMatching(const string &basename) const result.process_bytes(private_buffer,strlen(private_buffer)); } + bool basename_dir_exists = false; +#ifdef _WIN32 + int r = mkdir(basename.c_str()); +#else + int r = mkdir(basename.c_str(), 0777); +#endif + if (r < 0) + if (errno != EEXIST) + { + perror("ERROR"); + exit(EXIT_FAILURE); + } + else + basename_dir_exists = true; + // check whether basename directory exist. If not, create it. // If it does, read old checksum if it exist fstream checksum_file; string filename = basename + "/checksum"; unsigned int old_checksum = 0; - struct stat sd; - if (stat(basename.c_str(), &sd) != 0) - { - const int dir_err = mkdir(basename.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - if (dir_err == -1) - { - cerr << "ERROR: can't create directory " << basename << endl; - exit(EXIT_FAILURE); - } - } - else + // read old checksum if it exists + if (basename_dir_exists) { - // read old checksum if it exists checksum_file.open(filename.c_str(), ios::in | ios::binary); if (checksum_file.is_open()) { -- GitLab