Skip to content

Commit

Permalink
add check for .enc extension to support encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
hliu18 committed Oct 3, 2023
1 parent ced3b4f commit 78c41fa
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 78c41fa

Please sign in to comment.