| 1439 | |
| 1440 | |
| 1441 | bool CommandLine::SetParFilename(std::string filename) |
| 1442 | { |
| 1443 | bool result = false; |
| 1444 | |
| 1445 | #ifndef _WIN32 |
| 1446 | std::string::size_type where; |
| 1447 | |
| 1448 | if ((where = filename.find_first_of('*')) != std::string::npos || |
| 1449 | (where = filename.find_first_of('?')) != std::string::npos) |
| 1450 | { |
| 1451 | std::cerr << "par2 file must not have a wildcard in it." << std::endl; |
| 1452 | return result; |
| 1453 | } |
| 1454 | #endif |
| 1455 | |
| 1456 | // If we are verifying or repairing, the PAR2 file must |
| 1457 | // already exist |
| 1458 | if (operation != opCreate) |
| 1459 | { |
| 1460 | // Find the last '.' in the filename |
| 1461 | std::string::size_type where = filename.find_last_of('.'); |
| 1462 | if (where != std::string::npos) |
| 1463 | { |
| 1464 | // Get what follows the last '.' |
| 1465 | std::string tail = filename.substr(where+1); |
| 1466 | |
| 1467 | if (0 == stricmp(tail.c_str(), "par2")) |
| 1468 | { |
| 1469 | parfilename = filename; |
| 1470 | version = verPar2; |
| 1471 | } |
| 1472 | else if (0 == stricmp(tail.c_str(), "par") || |
| 1473 | (tail.size() == 3 && |
| 1474 | tolower(tail[0]) == 'p' && |
| 1475 | isdigit(tail[1]) && |
| 1476 | isdigit(tail[2]))) |
| 1477 | { |
| 1478 | parfilename = filename; |
| 1479 | version = verPar1; |
| 1480 | } |
| 1481 | |
| 1482 | if (DiskFile::FileExists(filename)) { |
| 1483 | result = true; |
| 1484 | } |
| 1485 | } |
| 1486 | |
| 1487 | // If we haven't figured out which version of PAR file we |
| 1488 | // are using from the file extension, then presumable the |
| 1489 | // files filename was actually the name of a data file. |
| 1490 | if (version == verUnknown) |
| 1491 | { |
| 1492 | // Check for the existence of a PAR2 of PAR file. |
| 1493 | if (DiskFile::FileExists(filename + ".par2")) |
| 1494 | { |
| 1495 | version = verPar2; |
| 1496 | parfilename = filename + ".par2"; |
| 1497 | result = true; |
| 1498 | } |
nothing calls this directly
no outgoing calls
no test coverage detected