MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / CreateFolder

Method CreateFolder

test/common/gtest/gtest.cpp:8595–8613  ·  view source on GitHub ↗

Create the directory so that path exists. Returns true if successful or if the directory already exists; returns false if unable to create the directory for any reason, including if the parent directory does not exist. Not named "CreateDirectory" because that's a macro on Windows.

Source from the content-addressed store, hash-verified

8593// directory for any reason, including if the parent directory does not
8594// exist. Not named "CreateDirectory" because that's a macro on Windows.
8595bool FilePath::CreateFolder() const {
8596#if GTEST_OS_WINDOWS_MOBILE
8597 FilePath removed_sep(this->RemoveTrailingPathSeparator());
8598 LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
8599 int result = CreateDirectory(unicode, NULL) ? 0 : -1;
8600 delete [] unicode;
8601#elif GTEST_OS_WINDOWS
8602 int result = _mkdir(pathname_.c_str());
8603#elif GTEST_OS_BARE_METAL
8604 int result = -1;
8605#else
8606 int result = mkdir(pathname_.c_str(), 0777);
8607#endif // GTEST_OS_WINDOWS_MOBILE
8608
8609 if (result == -1) {
8610 return this->DirectoryExists(); // An error is OK if the directory exists.
8611 }
8612 return true; // No error.
8613}
8614
8615// If input name has a trailing separator character, remove it and return the
8616// name, otherwise return the name string unmodified.

Callers 1

Calls 2

DirectoryExistsMethod · 0.95

Tested by

no test coverage detected