PhysiCell icon indicating copy to clipboard operation
PhysiCell copied to clipboard

handle abspath for output folder creation

Open drbergman opened this issue 4 months ago • 1 comments

any path starting with the path separator (indicating an absolute path) will cause an error with the current implementation even if the path already exists. This is because it attempts to create a directory with the empty string. This handles checking for that case. It splits on OS to check the path separator. For windows, it checks for the abspath starting with the drive. If we can upgrade to c++17, we could take advantage of std::filesystem to greatly simplify this. something like

// Function that we could use if we used c++17
// THIS IS NOT WHAT IS IMPLEMENTED IN THIS PR
bool create_directories(const std::string &path)
{
    std::error_code ec;
    bool success = std::filesystem::create_directories(path, ec);
    if (!success && ec) {
        // Handle error or log it, if necessary
        return false;
    }
    return true;
}

drbergman avatar Oct 23 '24 04:10 drbergman