diff --git a/docker/start.sh b/docker/start.sh index 264802a..fa8d308 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,7 +1,7 @@ #!/bin/bash chmod 777 output/licenceGenerator -#./output/licenceGenerator -cid=9f5449534443495461457815de0164a9 -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV +#./output/licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV cd output -./licenceGenerator -cid=9f5449534443495461457815de0164a9 -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV \ No newline at end of file +./licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV \ No newline at end of file diff --git a/include/licenceCommon.h b/include/licenceCommon.h index 65d74f9..b72a5a4 100644 --- a/include/licenceCommon.h +++ b/include/licenceCommon.h @@ -106,6 +106,10 @@ struct LicenceIdentification uint8_t licCompatibility = 1; // identikator hlavního ELC uint16_t licItemsCount = 0; + + string cid_cds_path = ""; + string licenceFilePath = ""; + }; struct LicData @@ -165,17 +169,14 @@ struct LicenceInfo11 class LicenceException : public std::exception { public: - // Constructor with int and string parameters LicenceException(int errorCode, const std::string &errorMessage) : errorCode_(errorCode), errorMessage_(errorMessage) {} - // Override the what() function to provide a description of the exception const char *what() const noexcept override { return errorMessage_.c_str(); } - // Getter functions for the exception members int getErrorCode() const { return errorCode_; diff --git a/include/licenceELC11.h b/include/licenceELC11.h index 0006003..103fe76 100644 --- a/include/licenceELC11.h +++ b/include/licenceELC11.h @@ -230,8 +230,7 @@ class LicenceELC11 private: SDCard sdCard; - const string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/ - const string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; + string cidString = ""; char cid[32] = {}; string csdString = ""; @@ -266,6 +265,8 @@ public: string operationErrors = ""; ErrorMessage errorMessage; + string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/ + string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; LicenceELC11(); ~LicenceELC11(); diff --git a/include/licenceELC21.h b/include/licenceELC21.h index 528ab93..cd9437d 100644 --- a/include/licenceELC21.h +++ b/include/licenceELC21.h @@ -13,8 +13,7 @@ using namespace std; class LicenceELC21 { - const string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/ - const string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; + enum class Error21 { @@ -88,6 +87,7 @@ class LicenceELC21 }; private: + int licItemCount = 0; LicenceBody licBody; LicenceIdentification lIdentification; @@ -107,6 +107,8 @@ class LicenceELC21 ErrorMessage errorMessage; LicenceInfo21 licenceInfo; + string cid_cdsPath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; ///sys/block/mmcblk0/device/ + string licenceFilePath = ""; //"c:\\_projects\\LicenceGenerator\\output\\"; LicenceELC21(); ~LicenceELC21(); diff --git a/include/licenceGenerator.h b/include/licenceGenerator.h index cc9d05b..4289841 100644 --- a/include/licenceGenerator.h +++ b/include/licenceGenerator.h @@ -26,13 +26,12 @@ using namespace std; int licenceIndex = 0; int compatibility = 0; string licenceFilePath = ""; + string cid_csd_filePath = ""; }; class LicenceGenerator { - - public: int elcSwitchType; string operationErrors = ""; diff --git a/licData.xml b/licData.xml new file mode 100644 index 0000000..9d502a7 --- /dev/null +++ b/licData.xml @@ -0,0 +1,32 @@ + + +EOV_OSV +WAGO +Licence pro EOV_OSV +start.cz +teco +Projekt XXX stanice YYY + + + Položka licence 1 + 666 + 100 + + + Položka licence 2 + 777 + 200 + + + Položka licence 3 + 888 + 300 + + + Položka licence 3 + 999 + 1600 + + + + \ No newline at end of file diff --git a/output/licDataOld.xml b/licDataOld.xml similarity index 86% rename from output/licDataOld.xml rename to licDataOld.xml index 824dbb8..b154968 100644 --- a/output/licDataOld.xml +++ b/licDataOld.xml @@ -4,5 +4,5 @@ EOV_OSV Licence pro EOV_OSV start.cz - wago + teco \ No newline at end of file diff --git a/output/___vzor_ezlic_eovosv0_wuygadtvxji.lic b/output/___vzor_ezlic_eovosv0_wuygadtvxji.lic deleted file mode 100644 index 0f5bb55..0000000 Binary files a/output/___vzor_ezlic_eovosv0_wuygadtvxji.lic and /dev/null differ diff --git a/output/cid b/output/cid index 32a9336..53e2b16 100644 --- a/output/cid +++ b/output/cid @@ -1,4 +1,4 @@ -9f5449534443495461457815de0164a9 +0353445355313647801b1a9f6600c747 6   . x4   .. nt$6 & manfid 6  cid "6  fwrev 6 Jm  csd ,6 gEd$ subsystem 46 % diff --git a/output/csd b/output/csd index 50b4809..7dee550 100644 --- a/output/csd +++ b/output/csd @@ -1,2 +1,2 @@ -400e00325b5900003a0d7f800a40008d +400e00325b59000076b27f800a404013 \ No newline at end of file diff --git a/output/ezlic_eovosv0_cbheemcjsii.lic b/output/ezlic_eovosv0_cbheemcjsii.lic new file mode 100644 index 0000000..062a7ee Binary files /dev/null and b/output/ezlic_eovosv0_cbheemcjsii.lic differ diff --git a/output/ezlic_eovosv0_jbyabqatxji.lic b/output/ezlic_eovosv0_jbyabqatxji.lic new file mode 100644 index 0000000..2b3dba0 Binary files /dev/null and b/output/ezlic_eovosv0_jbyabqatxji.lic differ diff --git a/output/ezlic_eovosv0_jjbaxgatxab.lic b/output/ezlic_eovosv0_jjbaxgatxab.lic new file mode 100644 index 0000000..d56235b Binary files /dev/null and b/output/ezlic_eovosv0_jjbaxgatxab.lic differ diff --git a/output/ezlic_eovosv0_jjfgcgtvxtb.lic b/output/ezlic_eovosv0_jjfgcgtvxtb.lic deleted file mode 100644 index 5f08e87..0000000 Binary files a/output/ezlic_eovosv0_jjfgcgtvxtb.lic and /dev/null differ diff --git a/output/ezlic_eovosv0_vdyeygcjeca.lic b/output/ezlic_eovosv0_vdyeygcjeca.lic new file mode 100644 index 0000000..fad502d Binary files /dev/null and b/output/ezlic_eovosv0_vdyeygcjeca.lic differ diff --git a/output/ezlic_eovosv0_wuygadtvxji.lic b/output/ezlic_eovosv0_wuygadtvxji.lic index f1f1f01..ac708f7 100644 Binary files a/output/ezlic_eovosv0_wuygadtvxji.lic and b/output/ezlic_eovosv0_wuygadtvxji.lic differ diff --git a/output/licData.xml b/output/licData.xml index efbf708..e1646db 100644 --- a/output/licData.xml +++ b/output/licData.xml @@ -3,8 +3,8 @@ EOV_OSV WAGO Licence pro EOV_OSV -start.cz -wago +eov.ceskatrebova.ddts.cz +eov2 Projekt XXX stanice YYY diff --git a/output/licenceGenerator b/output/licenceGenerator index bccbdd4..998a852 100644 Binary files a/output/licenceGenerator and b/output/licenceGenerator differ diff --git a/src/CreateLicence.cpp b/src/CreateLicence.cpp index 8253053..aba792c 100644 --- a/src/CreateLicence.cpp +++ b/src/CreateLicence.cpp @@ -1,29 +1,69 @@ #include -#include "plcLicence.h" #include "utils.h" -#include - - -#define FILEBUFFER 300 -#define TWO_HOURSE_SECONDS 7200 +#include "licenceGenerator.h" +#include "licenceCommon.h" /// @brief hlavní funkce /// @param argc /// @param argv parametry pro generování licence -/// 1-cid, 2-csd, 3-stanice 4-rozvadec 5-typ licence /// @return -int main5(int argc, char *argv[]) +int main(int argc, char *argv[]) { - unordered_map arguments = getArguments(argc, argv); + LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]); + generatorOld.createLicenceFile(); + return SUCCES; + + LicenceGenerator licenceGenerator = LicenceGenerator(); - PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], arguments["-outputType"], arguments["-configFileName"]); - if (plcWriteLicence.CreateLicence() == false) + InitStructure initStructure; + initStructure.elcType = 2; + initStructure.licenceType = (int)LicenceType::EOS_EOV; + initStructure.licenceVersion = 1; + initStructure.licenceIndex = 0; + initStructure.compatibility = 1; + initStructure.licenceFilePath = ""; + initStructure.cid_csd_filePath = ""; + + // //verze #1: načtení kompletní licence a zobrazení + // if (licenceGenerator.init(initStructure)) + // { + // LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) + // int protocolId = 345; + // if (licenceGenerator.getLicenceInfo(protocolId, &info)) + // { + // std::cout << "Počet licenčních bodů pro : " << protocolId << ": " << info.reqDataPointsCount << std::endl; + // if (info.licences.count(protocolId) > 0) cout << "počet z vectoru pro : " << protocolId << info.licences.at(888) << endl; + // cout << "všechny licenční body: " << endl; + // for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; } + // } + // else + // cerr << "Došlo k chybě: " << licenceGenerator.error.message; + // } + // else + // { + // cerr << "Došlo k chybě: " << licenceGenerator.error.message; + // } + + //verze #2 : iterace pro kazdý bod zvlášť + if (licenceGenerator.initread(initStructure)) { - cerr << "Licence creation failed"; + int protocolId = 888; + + LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) + + if (licenceGenerator.getLicenceItemInfo(protocolId, &info)) + { + std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl; + } + else + cerr << "Došlo k chybě: " << licenceGenerator.error.message; + } + else + { + cerr << "Došlo k chybě: " << licenceGenerator.error.message; } - - - return EXIT_SUCCESS; + system("pause"); + return SUCCES; } diff --git a/src/LicenceELC11.cpp b/src/LicenceELC11.cpp index 8364a21..eee457d 100644 --- a/src/LicenceELC11.cpp +++ b/src/LicenceELC11.cpp @@ -395,7 +395,7 @@ bool LicenceELC11::createEosEovLicence() else { dataToFile.header.licCount = 1; - dataToFile.items[1].licCount = 999;//65535; + dataToFile.items[1].licCount = 65535; // 65535; dataToFile.items[1].protoId = cEzLic_p78ou3_CheckLicNumberId_EOV1; dataToFile.items[1].data1 = cEzLic_p78ou3_CheckLicNumber_EOV1; } @@ -680,6 +680,9 @@ bool LicenceELC11::readLicence(LicenceInfoGeneral *licences) fileNameCh[i] = licFilePath[i]; licenceFile = fopen(fileNameCh, "rb"); // read mode + + if (licenceFile == nullptr) throw LicenceException((int)Error11::LicenceReadError, "Licence read error: " + licFilePath); + fseek(licenceFile, 0, SEEK_END); // seek to end of file const int size = ftell(licenceFile); // get current file pointer fseek(licenceFile, 0, SEEK_SET); @@ -728,10 +731,10 @@ bool LicenceELC11::readLicence(LicenceInfoGeneral *licences) // CryptData cryptData = initCrypto(sdData, licIdent.licIDType); unsigned char decrypted[2000] = {}; int decrypted_len = decrypt(encryptedData, sizeof(encryptedData), cryptData.aesKey, cryptData.aesInitVector, decrypted); - #ifdef DEB +#ifdef DEB cout << "sizeof(licEncryptedData: " << sizeof(licEncryptedData) << endl; cout << "decrypted_len: " << decrypted_len << endl; - #endif +#endif if (sizeof(licEncryptedData) != decrypted_len) { diff --git a/src/LicenceGenerator.cpp b/src/LicenceGenerator.cpp index 113f9d2..8cd5070 100644 --- a/src/LicenceGenerator.cpp +++ b/src/LicenceGenerator.cpp @@ -92,6 +92,8 @@ bool LicenceGenerator::initread(InitStructure &initStructure) case 11: { // old eoseov LicenceELC11 licence = LicenceELC11(this->licIdentification); + licence.cid_cdsPath = initStructure.cid_csd_filePath; + licence.licenceFilePath = initStructure.licenceFilePath;; licence.readLicence(&this->licenceInfo); break; } @@ -99,6 +101,8 @@ bool LicenceGenerator::initread(InitStructure &initStructure) { LicenceELC21 licence = LicenceELC21(this->licIdentification); this->licence21 = &licence; + licence.cid_cdsPath = initStructure.cid_csd_filePath; + licence.licenceFilePath = initStructure.licenceFilePath;; this->licence21->readLicence(&this->licenceInfo); break; } diff --git a/src/NewGeneration.cpp b/src/NewGeneration.cpp index 8380186..89bb6b5 100644 --- a/src/NewGeneration.cpp +++ b/src/NewGeneration.cpp @@ -1,20 +1,27 @@ +#define NEW =1 + +#ifdef NEW #include #include "utils.h" #include "licenceGenerator.h" #include "licenceCommon.h" +#define FILEBUFFER 300 +#define TWO_HOURSE_SECONDS 7200 + + /// @brief hlavní funkce /// @param argc /// @param argv parametry pro generování licence /// @return -int main(int argc, char *argv[]) +int main5(int argc, char *argv[]) { - // cout << "test" << endl; - // unordered_map arguments = getArguments(argc, argv); - // LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]); - // generatorOld.createLicenceFile(); - // return 0; - //cout << "Reading Test" << endl; + cout << "test" << endl; + unordered_map arguments = getArguments(argc, argv); + LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]); + generatorOld.createLicenceFile(); + return 0; + LicenceGenerator licenceGenerator = LicenceGenerator(); InitStructure initStructure; @@ -23,21 +30,20 @@ int main(int argc, char *argv[]) initStructure.licenceVersion = 1; initStructure.licenceIndex = 0; initStructure.compatibility = 1; - initStructure.licenceFilePath = ""; + initStructure.licenceFilePath = "test"; + initStructure.cid_csd_filePath = "test"; // if (licenceGenerator.init(initStructure)) // { // LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) - + // if (licenceGenerator.getLicenceInfo(888, &info)) // { // std::cout << "Počet licenčních bodů pro 888: " << info.reqDataPointsCount << std::endl; - // if (info.licences.count(888) > 0) cout << "počet z vectoru pro 888: " << info.licences.at(888) << endl; + // if (info.licences.count(888) > 0) + // cout << "počet z vectoru pro 888: " << info.licences.at(888) << endl; // cout << "všechny licenční body: " << endl; - - // for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; - // } - + // //for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; } // } // else // cerr << "Došlo k chybě: " << licenceGenerator.error.message; @@ -46,24 +52,56 @@ int main(int argc, char *argv[]) // { // cerr << "Došlo k chybě: " << licenceGenerator.error.message; // } - + if (licenceGenerator.initread(initStructure)) { LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) + if (licenceGenerator.getLicenceItemInfo(777, &info)) { std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl; - //for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; + // for (const auto& pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; } - else cerr << "Došlo k chybě: " << licenceGenerator.error.message; + else + cerr << "Došlo k chybě: " << licenceGenerator.error.message; } else { cerr << "Došlo k chybě: " << licenceGenerator.error.message; } - system("pause"); - - return EXIT_SUCCESS; + return 0; } +#endif + +#ifndef NEW + +#include +#include "utils.h" +#include "plcLicence.h" +// #include "licenceGenerator.h" +// #include "licenceCommon.h" + +#define FILEBUFFER 300 +#define TWO_HOURSE_SECONDS 7200 + + +/// @brief hlavní funkce +/// @param argc +/// @param argv parametry pro generování licence +/// @return +int main(int argc, char *argv[]) +{ + unordered_map arguments = getArguments(argc, argv); + PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], arguments["-outputType"], arguments["-configFileName"]); + if (plcWriteLicence.CreateLicence() == false) + { + cerr << "Licence creation failed"; + } + // cout << "Reading Test" << endl; + system("pause"); + return 0; +} + +#endif diff --git a/src/PlcLicence.cpp b/src/PlcLicence.cpp index b7fcecd..7a1a71b 100644 --- a/src/PlcLicence.cpp +++ b/src/PlcLicence.cpp @@ -330,6 +330,8 @@ bool PlcLicence::CreateEosEovLicence() dataToFile.id.version = 10; dataToFile.id.cardSize = this->sdData.cardSize; + cout << "cardSize: " << this->sdData.cardSize << endl; + switch (licIdent.licIDType) { case cEzLic_p78ou3_IDType_DDTS: @@ -348,6 +350,9 @@ bool PlcLicence::CreateEosEovLicence() dataToFile.header.licVersion = 10; dataToFile.header.licType = licIdent.licIDType; dataToFile.header.licDate = getLicDate(); // 1692230400; //getLicDate(); //1692144000;// getLicDate(); + + cout << "date:" << dataToFile.header.licDate << endl; + mainLicDescription += dataToFile.header.licDescription1; mainLicDescription += " ["; mainLicDescription += dataToFile.header.licDescription2; @@ -380,6 +385,10 @@ bool PlcLicence::CreateEosEovLicence() memcpy(byteArray, &dataToFile, sizeof(dataToFile)); + cout << endl; + for (auto x : byteArray) cout << (int)x << "-"; + cout << endl; + int finalEncryptedLength = encrypt(byteArray, sizeof(dataToFile), this->cryptData.aesKey, this->cryptData.aesInitVector, encrypted); if (licIdent.licPrefixType == cEzLic_p78ou3_LicPrefixType_ELC1) // typ1 = pouze zasifrovani dat diff --git a/src/licenceELC21.cpp b/src/licenceELC21.cpp index b704668..053deb9 100644 --- a/src/licenceELC21.cpp +++ b/src/licenceELC21.cpp @@ -115,6 +115,8 @@ bool LicenceELC21::createLicence() privateContent.push_back(crcComplete & 0xFF); privateContent.push_back((crcComplete >> 8) & 0xFF); + + privateContentEncrypted = cryptPrivateContent(privateContent); #ifdef DEB @@ -162,22 +164,19 @@ bool LicenceELC21::createLicence() bool LicenceELC21::readLicence(LicenceInfoGeneral * licences) { - try - { + // sdCard = SDCard("9f544930303030300000000b47015423", "400e00325b5900003a0d7f800a40008d"); sdCard = SDCard(this->cid_cdsPath); - if (sdCard.isLoaded == false) - throw LicenceException((int)Error21::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath); - + if (sdCard.isLoaded == false) throw LicenceException((int)Error21::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath); + string licFileName = getLicenceName(); string licFilePath = this->licenceFilePath+licFileName; - // Create an unsigned char vector to store the file data vector content; if (readFile(licFilePath, content) == false) { - throw LicenceException((int)GeneralError::FileOpenError, "Chyba otevření souboru licence."); + throw LicenceException((int)GeneralError::FileOpenError, "Chyba otevření souboru licence: " + licFilePath); } this->licBody.licId.licIdent[0] = content[0]; @@ -266,15 +265,6 @@ bool LicenceELC21::readLicence(LicenceInfoGeneral * licences) this->licenceInfo.licences.insert(pair(item.protoId, item.licCount)); licences->licences.insert(pair(item.protoId, item.licCount)); } - } - - catch (const LicenceException &ex) - { - errorMessage.code = ex.getErrorCode(); - errorMessage.message = ex.getErrorMessage(); - return false; - } - return true; } diff --git a/src/notes.txt b/src/notes.txt index cac018a..3ef4fd7 100644 --- a/src/notes.txt +++ b/src/notes.txt @@ -1,3 +1,105 @@ +10 +-0 +-0 +-0 +-79 +-58 +-0 +-0 +-2 +-0 +-10 +-0 +-128 +-92 +-114 +-101 +-115 +-116 +-97 +-114 +-116 +-46 +-99 +-122 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-116 +-101 +-99 +-111 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-1 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-0 +-1 +-0 +-255 +-255 +-21 +-17 +-97 +-225 +-0 +-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0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100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -960,8 +960,8 @@ string readFileToString(const std::string &filename, std::size_t sizeS) bool readFile(string fileName, vector &output) { std::ifstream file(fileName, std::ios::in | std::ios::binary); - - if (!file.is_open()) + + if (file.is_open() != 1) { return false; } @@ -973,6 +973,7 @@ bool readFile(string fileName, vector &output) output.push_back(byte); } + file.close(); // Get the size of the file // file.seekg(0, std::ios::end);