Skip to content

Commit

Permalink
mkdir_with_parents: skip existing directories
Browse files Browse the repository at this point in the history
  • Loading branch information
mmjconolly committed Jun 30, 2023
1 parent 3e27638 commit 487a52d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/util/mkdir_parents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ int mkdir_with_parents(const std::string &path, mode_t mode) {
slash_pos = path.find("/", slash_pos + 1);
std::string dir = path.substr(0, slash_pos);

struct stat s;
if ((stat(dir.c_str(), &s) != -1) && (S_ISDIR(s.st_mode) != 0)) continue;

if (0 != mkdir(dir.c_str(), mode) && errno != EEXIST) return errno;
}
return 0;
Expand Down

0 comments on commit 487a52d

Please sign in to comment.