MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ExecutablePathToSerial

Function ExecutablePathToSerial

pcsx2/CDVD/CDVD.cpp:525–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525static std::string ExecutablePathToSerial(const std::string& path)
526{
527 // cdrom:\SCES_123.45;1
528 std::string::size_type pos = path.rfind('\\');
529 std::string serial;
530 if (pos != std::string::npos)
531 {
532 serial = path.substr(pos + 1);
533 }
534 else
535 {
536 // cdrom:SCES_123.45;1
537 pos = path.rfind(':');
538 if (pos != std::string::npos)
539 serial = path.substr(pos + 1);
540 else
541 serial = path;
542 }
543
544 // strip off ; or version number
545 pos = serial.rfind(';');
546 if (pos != std::string::npos)
547 serial.erase(pos);
548
549 // check that it matches our expected format.
550 // this maintains the old behavior of PCSX2.
551 if (!StringUtil::WildcardMatch(serial.c_str(), "????_???.??*") &&
552 !StringUtil::WildcardMatch(serial.c_str(), "????""-???.??*")) // double quote because trigraphs
553 {
554 serial.clear();
555 }
556
557 // SCES_123.45 -> SCES-12345
558 for (std::string::size_type pos = 0; pos < serial.size();)
559 {
560 if (serial[pos] == '.')
561 {
562 serial.erase(pos, 1);
563 continue;
564 }
565
566 if (serial[pos] == '_')
567 serial[pos] = '-';
568 else
569 serial[pos] = static_cast<char>(std::toupper(serial[pos]));
570
571 pos++;
572 }
573
574 return serial;
575}
576
577void cdvdGetDiscInfo(std::string* out_serial, std::string* out_elf_path, std::string* out_version, u32* out_crc,
578 CDVDDiscType* out_disc_type)

Callers 1

cdvdGetDiscInfoFunction · 0.85

Calls 7

WildcardMatchFunction · 0.85
rfindMethod · 0.80
substrMethod · 0.80
eraseMethod · 0.45
c_strMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected