summaryrefslogtreecommitdiff
path: root/validate.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-12-07 23:42:31 -0500
committerJeffrey Walton <noloader@gmail.com>2018-12-07 23:42:31 -0500
commiteee358b025e08e326afddc6d175c56080b489d7e (patch)
treeef59d45023d4c82960c9266ca89d9a473c0fbdf7 /validate.h
parent5b0df2592ae8b843a35ff2809589bd469d0013f0 (diff)
downloadcryptopp-git-eee358b025e08e326afddc6d175c56080b489d7e.tar.gz
Fix DataDir for C++03 and below (GH #760)
Diffstat (limited to 'validate.h')
-rw-r--r--validate.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/validate.h b/validate.h
index 99b42a7c..607559c9 100644
--- a/validate.h
+++ b/validate.h
@@ -256,25 +256,28 @@ inline std::string AddSeparator(std::string str)
inline std::string DataDir(const std::string& filename)
{
+ std::string name;
std::ifstream file;
#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
// Data files in PWD are probably the newest. This is probably a build directory.
- file.open(std::string("./") + filename);
+ name = std::string("./") + filename;
+ file.open(name.c_str());
if (file.is_open())
- return std::string("./") + filename;
+ return name;
#endif
#ifdef CRYPTOPP_DATA_DIR
// Honor the user's setting next. This is likely an install directory if it is not "./".
- std::string data_dir(AddSeparator(CRYPTOPP_DATA_DIR));
- file.open(data_dir + filename);
+ name = AddSeparator(CRYPTOPP_DATA_DIR) + filename;
+ file.open(name.c_str());
if (file.is_open())
- data_dir + filename;
+ return name;
#endif
#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
// Finally look in {$ORIGIN}/bin/../share/
- file.open(std::string("../share/cryptopp/") + filename);
+ name = std::string("../share/cryptopp/") + filename;
+ file.open(name.c_str());
if (file.is_open())
- return std::string("../share/cryptopp/") + filename;
+ return name;
#endif
// This will cause the expected exception in the caller
return filename;