diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index 15a4c04..02a81fc 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -21,8 +21,11 @@ int initLogger(char *directoryPath) int buffer = 1; int returning; char *filePath = malloc(strlen(directoryPath) + strlen(LOG_FORMAT) + 1); + char *dateBuffer = malloc(strlen("yyyy-mm-dd") + 17); //TODO: MAKE THIS VARIABLE; FIND OUT WHY TF YOU NEED 17 MORE BYTES DIR *dir; + sprintf(dateBuffer, "%04d-%02d-%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); + //CREATE directoryPath DIRECTORY IF IT DOESN'T EXISTS ALREADY if (stat(directoryPath, &st) == -1) { @@ -35,9 +38,7 @@ int initLogger(char *directoryPath) { if (entry -> d_type == DT_REG) { - if (strcmp(entry -> d_name, ".gitkeep") == 0) continue; - - buffer++; + if (strncmp(dateBuffer, entry -> d_name, strlen(dateBuffer)) == 0) buffer++; } } @@ -49,6 +50,7 @@ int initLogger(char *directoryPath) //DEALLOCATION free(filePath); + free(dateBuffer); closedir(dir); return returning;