simplified getting content of fileBuffer in checkVersion

i have no idea why it was like that
This commit is contained in:
Václav Šmejkal 2022-05-29 18:40:33 +02:00
parent 7714e45019
commit 96945a4d31
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19

View File

@ -52,25 +52,24 @@ void checkVersion(inputFlags flags)
//JSON VARIABLES //JSON VARIABLES
char *buffer; char *buffer;
char lineBuffer[32];
struct json_object *parsedJson; struct json_object *parsedJson;
struct json_object *active; struct json_object *active;
int bufferSize;
//COUNT LENGTH OF buffer //COUNT LENGTH OF buffer AND STORE IT IN bufferSize
fileBuffer = fopen(VERSIONS_NAME, "r"); fileBuffer = fopen(VERSIONS_NAME, "r");
fseek(fileBuffer, 0, SEEK_END); fseek(fileBuffer, 0, SEEK_END);
buffer = malloc(ftell(fileBuffer)); bufferSize = ftell(fileBuffer);
rewind(fileBuffer); //REWIND fileBuffer (NO SHIT) rewind(fileBuffer); //REWIND fileBuffer (NO SHIT)
//SET LENGTH OF buffer
buffer = malloc(bufferSize);
//FIX buffer //FIX buffer
strcpy(buffer, ""); strcpy(buffer, "");
//LOAD jsonFile //LOAD jsonFile
while (fgets(lineBuffer, sizeof(lineBuffer), fileBuffer) != NULL) fread(buffer, bufferSize, 1, fileBuffer);
{
strcat(buffer, lineBuffer);
}
//CHECK FOR TEXT IN buffer //CHECK FOR TEXT IN buffer
if (strcmp(buffer, "") == 0) if (strcmp(buffer, "") == 0)