MCPcopy Create free account
hub / github.com/AGWA/git-crypt / mkdir_parent

Function mkdir_parent

util-unix.cpp:103–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void mkdir_parent (const std::string& path)
104{
105 std::string::size_type slash(path.find('/', 1));
106 while (slash != std::string::npos) {
107 std::string prefix(path.substr(0, slash));
108 struct stat status;
109 if (stat(prefix.c_str(), &status) == 0) {
110 // already exists - make sure it's a directory
111 if (!S_ISDIR(status.st_mode)) {
112 throw System_error("mkdir_parent", prefix, ENOTDIR);
113 }
114 } else {
115 if (errno != ENOENT) {
116 throw System_error("mkdir_parent", prefix, errno);
117 }
118 // doesn't exist - mkdir it
119 if (mkdir(prefix.c_str(), 0777) == -1) {
120 throw System_error("mkdir", prefix, errno);
121 }
122 }
123
124 slash = path.find('/', slash + 1);
125 }
126}
127
128std::string our_exe_path ()
129{

Callers 3

encrypt_repo_keyFunction · 0.70
initFunction · 0.70
unlockFunction · 0.70

Calls 2

statClass · 0.85
System_errorClass · 0.85

Tested by

no test coverage detected