MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / CreateFolder

Method CreateFolder

tests/gtest/gtest-all.cc:9555–9571  ·  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

9553// directory for any reason, including if the parent directory does not
9554// exist. Not named "CreateDirectory" because that's a macro on Windows.
9555bool FilePath::CreateFolder() const {
9556#if GTEST_OS_WINDOWS_MOBILE
9557 FilePath removed_sep(this->RemoveTrailingPathSeparator());
9558 LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
9559 int result = CreateDirectory(unicode, nullptr) ? 0 : -1;
9560 delete [] unicode;
9561#elif GTEST_OS_WINDOWS
9562 int result = _mkdir(pathname_.c_str());
9563#else
9564 int result = mkdir(pathname_.c_str(), 0777);
9565#endif // GTEST_OS_WINDOWS_MOBILE
9566
9567 if (result == -1) {
9568 return this->DirectoryExists(); // An error is OK if the directory exists.
9569 }
9570 return true; // No error.
9571}
9572
9573// If input name has a trailing separator character, remove it and return the
9574// name, otherwise return the name string unmodified.

Callers 1

Calls 2

DirectoryExistsMethod · 0.95

Tested by

no test coverage detected