From b2421887a166417a15550260827be51dcc364e76 Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 21 Oct 2019 11:27:27 +0000 Subject: [PATCH] Use stat() instead of fopen() to detect existing files when saving screenshots git-svn-id: https://svn.eduke32.com/eduke32@8246 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/screenshot.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/build/src/screenshot.cpp b/source/build/src/screenshot.cpp index 1d00673ee..48a97e377 100644 --- a/source/build/src/screenshot.cpp +++ b/source/build/src/screenshot.cpp @@ -13,8 +13,6 @@ buildvfs_FILE OutputFileCounter::opennextfile(char *fn, char *zeros) { - buildvfs_FILE file; - do // JBF 2004022: So we don't overwrite existing screenshots { if (count > 9999) return nullptr; @@ -23,9 +21,14 @@ buildvfs_FILE OutputFileCounter::opennextfile(char *fn, char *zeros) zeros[1] = ((count/100)%10)+'0'; zeros[2] = ((count/10)%10)+'0'; zeros[3] = (count%10)+'0'; - +#ifdef USE_PHYSFS + buildvfs_FILE file; if ((file = buildvfs_fopen_read(fn)) == nullptr) break; buildvfs_fclose(file); +#else + struct Bstat st; + if (Bstat(fn, &st) == -1) break; +#endif count++; } while (1);