From fbcdb4b11f283e98e82ca7d4909c016813e1585f Mon Sep 17 00:00:00 2001 From: Huisheng Liu Date: Tue, 3 Oct 2023 11:13:20 -0700 Subject: [PATCH] add check for .enc extension to support encryption --- include/utils.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/include/utils.h b/include/utils.h index 58bb52a3b..77e5743ba 100644 --- a/include/utils.h +++ b/include/utils.h @@ -57,7 +57,7 @@ typedef int FileHandle; #define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" #define PBWIDTH 60 -inline bool file_exists(const std::string &name, bool dirCheck = false) +inline bool file_exists_impl(const std::string &name, bool dirCheck = false) { int val; #ifndef _WINDOWS @@ -94,6 +94,29 @@ inline bool file_exists(const std::string &name, bool dirCheck = false) } } +inline bool file_exists(const std::string &name, bool dirCheck = false) +{ +#ifdef EXEC_ENV_OLS + bool exists = file_exists_impl(name, dirCheck); + if (exists) + { + return true; + } + if (!dirCheck) + { + // try with .enc extension + std::string enc_name = name + ENCRYPTED_EXTENSION; + return file_exists_impl(enc_name, dirCheck); + } + else + { + return exists; + } +#else + return file_exists_impl(name, dirCheck); +#endif +} + inline void open_file_to_write(std::ofstream &writer, const std::string &filename) { writer.exceptions(std::ofstream::failbit | std::ofstream::badbit);