From b40b2c031a5e10f447d6f2128bb5186c89422876 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 2 Sep 2016 13:00:56 -0700 Subject: [PATCH] Better temp file handling --- lib/ContainerRegistry.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ContainerRegistry.cpp b/lib/ContainerRegistry.cpp index e4b3e87..9093012 100644 --- a/lib/ContainerRegistry.cpp +++ b/lib/ContainerRegistry.cpp @@ -560,7 +560,8 @@ static std::vector> LoadMP2(FIL rem -= dsz; } - fp = FOpen(_S("amuse_tmp.dat"), _S("r+")); + fp = FOpen(_S("amuse_tmp.dat"), _S("rw")); + rewind(fp); fwrite(buf, 1, decompSz, fp); rewind(fp); } @@ -609,7 +610,11 @@ static std::vector> LoadMP2(FIL } } } - Unlink(_S("amuse_tmp.dat")); + if (compressed) + { + fclose(fp); + Unlink(_S("amuse_tmp.dat")); + } fp = old_fp; FSeek(fp, origPos, SEEK_SET); }