| 18 | using namespace std; |
| 19 | |
| 20 | OriginFile::OriginFile(const string &fileName) : fileVersion(0), buildVersion(0), ioError(0) |
| 21 | { |
| 22 | ifstream file(fileName.c_str(), ios_base::binary); |
| 23 | |
| 24 | if (!file.is_open()) { |
| 25 | ioError = errno; |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | #ifdef GENERATE_CODE_FOR_LOG |
| 30 | FILE *logfile = nullptr; |
| 31 | logfile = fopen("./opjfile.log", "w"); |
| 32 | if (logfile == nullptr) { |
| 33 | ioError = errno; |
| 34 | return; |
| 35 | } |
| 36 | #endif // GENERATE_CODE_FOR_LOG |
| 37 | LOG_PRINT(logfile, "File: %s\n", fileName.c_str()) |
| 38 | |
| 39 | string vers; |
| 40 | getline(file, vers); |
| 41 | file.close(); |
| 42 | |
| 43 | long majorVersion = strtol(vers.substr(5, 1).c_str(), nullptr, 10); |
| 44 | // char locale_decpoint = vers[6]; |
| 45 | buildVersion = strtol(vers.substr(7).c_str(), nullptr, 10); |
| 46 | // long buildNumber = strtol(vers.substr(12).c_str(),0,10); |
| 47 | |
| 48 | // translate version |
| 49 | // see https://www.originlab.com/index.aspx?go=SUPPORT&pid=3325 |
| 50 | unsigned int newFileVersion = 0; |
| 51 | if (majorVersion == 3) { |
| 52 | if (buildVersion < 830) |
| 53 | fileVersion = 350; |
| 54 | else |
| 55 | fileVersion = 410; |
| 56 | } else if (buildVersion >= 110 && buildVersion <= 141) // 4.1 |
| 57 | fileVersion = 410; |
| 58 | else if (buildVersion <= 210) // 5.0 |
| 59 | fileVersion = 500; |
| 60 | else if (buildVersion < 2624) // 6.0 |
| 61 | fileVersion = 600; |
| 62 | else if (buildVersion < 2628) // 6.0 SR1 |
| 63 | fileVersion = 601; |
| 64 | else if (buildVersion < 2635) // 6.0 SR4 |
| 65 | fileVersion = 604; |
| 66 | else if (buildVersion < 2656) // 6.1 |
| 67 | fileVersion = 610; |
| 68 | else if (buildVersion < 2659) // 7.0 SR0 (2656-2658) |
| 69 | fileVersion = 700; |
| 70 | else if (buildVersion < 2664) // 7.0 SR1 (2659-2663) |
| 71 | fileVersion = 701; |
| 72 | else if (buildVersion < 2672) // 7.0 SR2 (2664-2671) |
| 73 | fileVersion = 702; |
| 74 | else if (buildVersion < 2673) // 7.0 SR3 (2672-2672) |
| 75 | fileVersion = 703; |
| 76 | else if (buildVersion < 2766) // 7.0 SR4 (2673-2765) |
| 77 | fileVersion = 704; |
nothing calls this directly
no test coverage detected