diff --git a/modules/PhysiCell_settings.cpp b/modules/PhysiCell_settings.cpp index 3937fb8c6..2fe8bbaf7 100644 --- a/modules/PhysiCell_settings.cpp +++ b/modules/PhysiCell_settings.cpp @@ -325,11 +325,20 @@ void PhysiCell_Settings::read_from_pugixml( void ) bool create_directories(const std::string &path) { - std::vector directories; - size_t pos = 0; + size_t pos = 0; std::string currentPath; - while ((pos = path.find_first_of("/\\", pos)) != std::string::npos) { + // Check for Unix-like absolute path or Windows absolute path with drive letter + if (path[0] == '\\' || path[0] == '/') + { + pos = 1; // Unix-like or Windows absolute path starting with backslash or forward slash + } + else if (path.length() > 2 && isalpha(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/')) + { + pos = 3; // Windows absolute path with drive letter + } + + while ((pos = path.find_first_of("/\\", pos)) != std::string::npos) { currentPath = path.substr(0, pos++); if (!create_directory(currentPath)) { return false;