Skip to content
Snippets Groups Projects
Commit e2135c36 authored by rswindell's avatar rswindell
Browse files

iniWriteFile(): don't truncate the file to 0-bytes before writing the contents,

instead truncate to the new length after writing the contents. This should
make .ini files more tolerate of "out of disk space" situations and reduce
the risk of lost data (0-byte .ini files) due to low/no disk space.
parent 7d9f8d0e
Branches
Tags
No related merge requests found
...@@ -2361,11 +2361,10 @@ BOOL DLLCALL iniWriteFile(FILE* fp, const str_list_t list) ...@@ -2361,11 +2361,10 @@ BOOL DLLCALL iniWriteFile(FILE* fp, const str_list_t list)
size_t count; size_t count;
rewind(fp); rewind(fp);
if(chsize(fileno(fp),0)!=0) /* truncate */
return(FALSE);
count = strListWriteFile(fp,list,"\n"); count = strListWriteFile(fp,list,"\n");
fflush(fp);
if(chsize(fileno(fp), ftell(fp))!=0) /* truncate */
return(FALSE);
return(count == strListCount(list)); return(count == strListCount(list));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment