Skip to content
Snippets Groups Projects
Commit 1080ab0d authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix new function: fopenlog()

ftello() returns 0 after fnopen(..., O_APPEND). Use filelength() instead.
parent cfd62425
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2988 passed
...@@ -216,12 +216,13 @@ BOOL backup(const char *fname, int backup_level, BOOL ren) ...@@ -216,12 +216,13 @@ BOOL backup(const char *fname, int backup_level, BOOL ren)
FILE* fopenlog(scfg_t* cfg, const char* path) FILE* fopenlog(scfg_t* cfg, const char* path)
{ {
const int mode = O_WRONLY|O_CREAT|O_APPEND; const int mode = O_WRONLY|O_CREAT|O_APPEND;
int file;
FILE* fp; FILE* fp;
if((fp = fnopen(NULL, path, mode)) == NULL) if((fp = fnopen(&file, path, mode)) == NULL)
return NULL; return NULL;
if(cfg->max_log_size && cfg->max_logs_kept && ftello(fp) >= (off_t)cfg->max_log_size) { if(cfg->max_log_size && cfg->max_logs_kept && filelength(file) >= (off_t)cfg->max_log_size) {
#ifdef _WIN32 // Can't rename an open file on Windows #ifdef _WIN32 // Can't rename an open file on Windows
fclose(fp); fclose(fp);
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment