| 137 | } |
| 138 | |
| 139 | int CheckpointReceiver :: InitFilePath(const std::string & sFilePath, std::string & sFormatFilePath) |
| 140 | { |
| 141 | PLGHead("START filepath %s", sFilePath.c_str()); |
| 142 | |
| 143 | string sNewFilePath = "/" + sFilePath + "/"; |
| 144 | vector<std::string> vecDirList; |
| 145 | |
| 146 | std::string sDirName; |
| 147 | for (size_t i = 0; i < sNewFilePath.size(); i++) |
| 148 | { |
| 149 | if (sNewFilePath[i] == '/') |
| 150 | { |
| 151 | if (sDirName.size() > 0) |
| 152 | { |
| 153 | vecDirList.push_back(sDirName); |
| 154 | } |
| 155 | |
| 156 | sDirName = ""; |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | sDirName += sNewFilePath[i]; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | sFormatFilePath = ""; |
| 165 | if (vecDirList.size() > 0 && vecDirList[0].size() > 0 && vecDirList[0][0] != '.') |
| 166 | { |
| 167 | sFormatFilePath += "/"; |
| 168 | } |
| 169 | |
| 170 | for (size_t i = 0; i < vecDirList.size(); i++) |
| 171 | { |
| 172 | if (i + 1 == vecDirList.size()) |
| 173 | { |
| 174 | sFormatFilePath += vecDirList[i]; |
| 175 | } |
| 176 | else |
| 177 | { |
| 178 | sFormatFilePath += vecDirList[i] + "/"; |
| 179 | if (m_mapHasInitDir.find(sFormatFilePath) == end(m_mapHasInitDir)) |
| 180 | { |
| 181 | int ret = CreateDir(sFormatFilePath); |
| 182 | if (ret != 0) |
| 183 | { |
| 184 | return ret; |
| 185 | } |
| 186 | |
| 187 | m_mapHasInitDir[sFormatFilePath] = true; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | PLGImp("ok, format filepath %s", sFormatFilePath.c_str()); |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |