MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / MakePath

Function MakePath

util/src/FileSystem.cpp:314–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312 }
313
314 void
315 MakePath(std::string const& path)
316 {
317 std::string subPath;
318 auto dirs = SplitString(path, std::string() + DIR_SEP_WIN32 + DIR_SEP_POSIX);
319 if (dirs.empty())
320 {
321 return;
322 }
323
324 auto iter = dirs.begin();
325#ifdef US_PLATFORM_POSIX
326 // Start with the root '/' directory
327 subPath = DIR_SEP;
328#else
329 // Start with the drive letter`
330 subPath = *iter + DIR_SEP;
331 ++iter;
332#endif
333 for (; iter != dirs.end(); ++iter)
334 {
335 subPath += *iter;
336 errno = 0;
337#ifdef US_PLATFORM_WINDOWS
338 if (us_mkdir(subPath.c_str()))
339#else
340 if (us_mkdir(subPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
341#endif
342 {
343 if (errno != EEXIST)
344 {
345 throw std::invalid_argument(GetLastCErrorStr());
346 }
347 }
348 subPath += DIR_SEP;
349 }
350 }
351
352 void
353 RemoveDirectoryRecursive(std::string const& path)

Callers 4

createDirHierarchyFunction · 0.85
TEST_FFunction · 0.85
GetDataFileMethod · 0.85
GetPersistentStoragePathFunction · 0.85

Calls 5

SplitStringFunction · 0.85
GetLastCErrorStrFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 2

createDirHierarchyFunction · 0.68
TEST_FFunction · 0.68