File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6464# #
6565###############################################################################
6666*/
67+
68+ #include < version>
69+
70+ #ifdef __cpp_lib_filesystem
71+ #include < filesystem>
72+ #endif
6773
6874#include < sys/stat.h>
6975#include " ./PhysiCell_settings.h"
76+ #include " ../core/PhysiCell_cell.h"
7077
7178using namespace BioFVM ;
7279
@@ -355,15 +362,30 @@ bool create_directories(const std::string &path)
355362 return create_directory (path);
356363}
357364
365+ #ifdef __cpp_lib_filesystem
358366bool create_directory (const std::string &path)
359367{
360- #if defined(_WIN32)
368+ // Create the directory using C++17 filesystem library
369+ std::error_code ec; // To capture any error
370+ if (std::filesystem::create_directories (path, ec)) {
371+ return true ; // Directory created successfully
372+ } else if (ec) {
373+ std::cerr << " Error creating directory " << path << " : " << ec.message () << std::endl;
374+ return false ; // An error occurred
375+ }
376+ return true ; // Directory already exists
377+ }
378+ #else
379+ bool create_directory (const std::string &path)
380+ {
381+ #if defined(__MINGW32__) || defined(__MINGW64__)
361382 bool success = mkdir (path.c_str ()) == 0 ;
362383#else
363384 bool success = mkdir (path.c_str (), 0755 ) == 0 ;
364385#endif
365386 return success || errno == EEXIST ;
366387}
388+ #endif
367389
368390void create_output_directory (const std::string& path)
369391{
You can’t perform that action at this time.
0 commit comments