MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / createPath

Method createPath

src/thundersvm/util/log.cpp:702–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700 }
701
702 bool File::createPath(const std::string& path) {
703 if (path.empty()) {
704 return false;
705 }
706 if (base::utils::File::pathExists(path.c_str())) {
707 return true;
708 }
709 int status = -1;
710
711 char* currPath = const_cast<char*>(path.c_str());
712 std::string builtPath = std::string();
713#if ELPP_OS_UNIX
714 if (path[0] == '/') {
715 builtPath = "/";
716 }
717 currPath = STRTOK(currPath, base::consts::kFilePathSeperator, 0);
718#elif ELPP_OS_WINDOWS
719 // Use secure functions API
720 char* nextTok_ = nullptr;
721 currPath = STRTOK(currPath, base::consts::kFilePathSeperator, &nextTok_);
722 ELPP_UNUSED(nextTok_);
723#endif // ELPP_OS_UNIX
724 while (currPath != nullptr) {
725 builtPath.append(currPath);
726 builtPath.append(base::consts::kFilePathSeperator);
727#if ELPP_OS_UNIX
728 status = mkdir(builtPath.c_str(), ELPP_LOG_PERMS);
729 currPath = STRTOK(nullptr, base::consts::kFilePathSeperator, 0);
730#elif ELPP_OS_WINDOWS
731 status = _mkdir(builtPath.c_str());
732 currPath = STRTOK(nullptr, base::consts::kFilePathSeperator, &nextTok_);
733#endif // ELPP_OS_UNIX
734 }
735 if (status == -1) {
736 ELPP_INTERNAL_ERROR("Error while creating path [" << path << "]", true);
737 return false;
738 }
739 return true;
740 }
741
742 std::string File::extractPathFromFilename(const std::string& fullPath, const char* separator) {
743 if ((fullPath == "") || (fullPath.find(separator) == std::string::npos)) {

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected