summaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/file_util.cpp')
-rw-r--r--src/common/file_util.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 40b633092..2152e3fea 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -257,7 +257,7 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename) {
257 return true; 257 return true;
258#endif 258#endif
259 LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, 259 LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename,
260 GetLastErrorMsg()); 260 GetLastErrorMsg());
261 return false; 261 return false;
262} 262}
263 263
@@ -270,7 +270,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) {
270 return true; 270 return true;
271 271
272 LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, 272 LOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename,
273 GetLastErrorMsg()); 273 GetLastErrorMsg());
274 return false; 274 return false;
275#else 275#else
276 276
@@ -283,7 +283,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) {
283 FILE* input = fopen(srcFilename.c_str(), "rb"); 283 FILE* input = fopen(srcFilename.c_str(), "rb");
284 if (!input) { 284 if (!input) {
285 LOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, 285 LOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename,
286 destFilename, GetLastErrorMsg()); 286 destFilename, GetLastErrorMsg());
287 return false; 287 return false;
288 } 288 }
289 289
@@ -292,7 +292,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) {
292 if (!output) { 292 if (!output) {
293 fclose(input); 293 fclose(input);
294 LOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, 294 LOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename,
295 destFilename, GetLastErrorMsg()); 295 destFilename, GetLastErrorMsg());
296 return false; 296 return false;
297 } 297 }
298 298
@@ -303,7 +303,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) {
303 if (rnum != BSIZE) { 303 if (rnum != BSIZE) {
304 if (ferror(input) != 0) { 304 if (ferror(input) != 0) {
305 LOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", 305 LOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}",
306 srcFilename, destFilename, GetLastErrorMsg()); 306 srcFilename, destFilename, GetLastErrorMsg());
307 goto bail; 307 goto bail;
308 } 308 }
309 } 309 }
@@ -312,7 +312,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) {
312 size_t wnum = fwrite(buffer, sizeof(char), rnum, output); 312 size_t wnum = fwrite(buffer, sizeof(char), rnum, output);
313 if (wnum != rnum) { 313 if (wnum != rnum) {
314 LOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, 314 LOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename,
315 destFilename, GetLastErrorMsg()); 315 destFilename, GetLastErrorMsg());
316 goto bail; 316 goto bail;
317 } 317 }
318 } 318 }
@@ -371,14 +371,12 @@ u64 GetSize(FILE* f) {
371 // can't use off_t here because it can be 32-bit 371 // can't use off_t here because it can be 32-bit
372 u64 pos = ftello(f); 372 u64 pos = ftello(f);
373 if (fseeko(f, 0, SEEK_END) != 0) { 373 if (fseeko(f, 0, SEEK_END) != 0) {
374 LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), 374 LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), GetLastErrorMsg());
375 GetLastErrorMsg());
376 return 0; 375 return 0;
377 } 376 }
378 u64 size = ftello(f); 377 u64 size = ftello(f);
379 if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { 378 if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) {
380 LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), 379 LOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), GetLastErrorMsg());
381 GetLastErrorMsg());
382 return 0; 380 return 0;
383 } 381 }
384 return size; 382 return size;