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
Branches
Tags
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)
FILE* fopenlog(scfg_t* cfg, const char* path)
{
const int mode = O_WRONLY|O_CREAT|O_APPEND;
int file;
FILE* fp;
if((fp = fnopen(NULL, path, mode)) == NULL)
if((fp = fnopen(&file, path, mode)) == 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
fclose(fp);
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment