From b0fc8fb46cb6018fb4c43746063fe5168d5c816d Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 10 Sep 2022 00:06:26 +0200 Subject: [PATCH] Add utility for checking if a file is empty or not --- r5dev/public/utility/utility.cpp | 7 +++++++ r5dev/public/utility/utility.h | 1 + 2 files changed, 8 insertions(+) diff --git a/r5dev/public/utility/utility.cpp b/r5dev/public/utility/utility.cpp index 23e912f5..7fcf5683 100644 --- a/r5dev/public/utility/utility.cpp +++ b/r5dev/public/utility/utility.cpp @@ -13,6 +13,13 @@ BOOL FileExists(const fs::path& svFilePath) return fs::exists(svFilePath); } +/////////////////////////////////////////////////////////////////////////////// +// For checking if a specific file is empty. +BOOL FileEmpty(ifstream& pFile) +{ + return pFile.peek() == ifstream::traits_type::eof(); +} + /////////////////////////////////////////////////////////////////////////////// // For checking if pointer is valid or bad. BOOL IsBadReadPtrV2(void* ptr) diff --git a/r5dev/public/utility/utility.h b/r5dev/public/utility/utility.h index 2db853ba..d6595544 100644 --- a/r5dev/public/utility/utility.h +++ b/r5dev/public/utility/utility.h @@ -4,6 +4,7 @@ // Internals BOOL IsBadReadPtrV2(void* ptr); BOOL FileExists(const fs::path& svFilePath); +BOOL FileEmpty(ifstream& pFile); MODULEINFO GetModuleInfo(const char* szModule); /////////////////////////////////////////////////////////////////////////////