|
3 | 3 | #include <string.h>
|
4 | 4 | #include <map>
|
5 | 5 | #include <fstream>
|
| 6 | +#include <sstream> |
6 | 7 | #include <iostream>
|
7 | 8 | #include <string>
|
8 | 9 | #include <direct.h>
|
@@ -299,18 +300,32 @@ bool CMountProg::ReadPathsFromFile(char* sFileName)
|
299 | 300 | std::ifstream pathFile(sFileName);
|
300 | 301 |
|
301 | 302 | if (pathFile.is_open()) {
|
302 |
| - std::string line; |
| 303 | + std::string line, path; |
| 304 | + std::vector<std::string> paths; |
| 305 | + std::istringstream ss; |
303 | 306 |
|
304 | 307 | while (std::getline(pathFile, line)) {
|
305 |
| - char *pCurPath = (char*)malloc(line.size() + 1); |
306 |
| - pCurPath = (char*)line.c_str(); |
| 308 | + ss.clear(); |
| 309 | + paths.clear(); |
| 310 | + ss.str(line); |
307 | 311 |
|
308 |
| - if (pCurPath != NULL) { |
309 |
| - char curPathAlias[MAXPATHLEN]; |
310 |
| - strcpy_s(curPathAlias, pCurPath); |
311 |
| - char *pCurPathAlias = (char*)malloc(strlen(curPathAlias)); |
312 |
| - pCurPathAlias = curPathAlias; |
| 312 | + // split path and alias separated by '>' |
| 313 | + while (std::getline(ss, path, '>')) { |
| 314 | + paths.push_back(path); |
| 315 | + } |
| 316 | + if (paths.size() < 1) { |
| 317 | + continue; |
| 318 | + } |
| 319 | + if (paths.size() < 2) { |
| 320 | + paths.push_back(paths[0]); |
| 321 | + } |
313 | 322 |
|
| 323 | + char *pCurPath = (char*)malloc(paths[0].size() + 1); |
| 324 | + pCurPath = (char*)paths[0].c_str(); |
| 325 | + |
| 326 | + if (pCurPath != NULL) { |
| 327 | + char *pCurPathAlias = (char*)malloc(paths[1].size() + 1); |
| 328 | + pCurPathAlias = (char*)paths[1].c_str(); |
314 | 329 | Export(pCurPath, pCurPathAlias);
|
315 | 330 | }
|
316 | 331 | }
|
|
0 commit comments