MCPcopy Create free account
hub / github.com/Tencent/phxsql / CheckDir

Method CheckDir

phxcomm/utils/phx_utils.cpp:52–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void Utils::CheckDir(const string &dir) {
53 size_t pos = 0;
54 while (1) {
55 if (pos == dir.size()) {
56 break;
57 }
58 string check_dir;
59 size_t next_pos = dir.find('/', pos);
60 if (next_pos == string::npos) {
61 pos = dir.size();
62 check_dir = dir;
63 } else {
64 pos = next_pos + 1;
65 check_dir = dir.substr(0, pos);
66 }
67 //check dir if exist
68 struct stat fileStat;
69 if ((stat(check_dir.c_str(), &fileStat) == 0) && S_ISDIR(fileStat.st_mode)) {
70 //exist;
71 } else {
72 //create dir
73 int ret = mkdir(check_dir.c_str(), 0777);
74 if (ret) {
75 ColorLogError("create dir %s( check %s ) fail %s ret %d", dir.c_str(), check_dir.c_str(),
76 strerror(errno), ret);
77 assert(ret == 0);
78 }
79 ColorLogInfo("%s create dir %s done", __func__, check_dir.c_str());
80 }
81 }
82}
83
84uint32_t Utils::GetFileTime(const string &filename) {
85 if (filename.empty())

Callers

nothing calls this directly

Calls 3

ColorLogErrorFunction · 0.85
ColorLogInfoFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected