Update comments

pull/795/head
Jeffrey Walton 2019-02-02 00:47:56 -05:00
parent 96eac11d3b
commit 1b8c00b37c
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 14 additions and 6 deletions

View File

@ -266,17 +266,18 @@ inline std::string AddSeparator(std::string str)
return str; return str;
} }
// Use CRYPTOPP_DATA_DIR last. The problem this sidesteps is, finding an
// old version of Crypto++ library in CRYPTOPP_DATA_DIR when the library
// has been staged in DESTDIR. Using CRYPTOPP_DATA_DIR first only works
// as expected when CRYPTOPP_DATA_DIR is empty before an install. We
// encountered this problem rather quickly during testing of Crypto++ 8.1
// when Crypto++ 8.0 was installed locally. It took some time to realize
// where the old test data was coming from.
static std::string GetDataDir() static std::string GetDataDir()
{ {
std::ifstream file; std::ifstream file;
std::string name, filename = "TestData/usage.dat"; std::string name, filename = "TestData/usage.dat";
#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
name = AddSeparator(g_argvPathHint) + filename;
file.open(name.c_str());
if (file.is_open())
return AddSeparator(g_argvPathHint);
#endif
#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH #ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
// Look in $ORIGIN/../share/. This is likely a Linux install directory. // Look in $ORIGIN/../share/. This is likely a Linux install directory.
name = AddSeparator(g_argvPathHint) + std::string("../share/cryptopp/") + filename; name = AddSeparator(g_argvPathHint) + std::string("../share/cryptopp/") + filename;
@ -284,6 +285,13 @@ static std::string GetDataDir()
if (file.is_open()) if (file.is_open())
return AddSeparator(g_argvPathHint) + std::string("../share/cryptopp/"); return AddSeparator(g_argvPathHint) + std::string("../share/cryptopp/");
#endif #endif
#ifndef CRYPTOPP_DISABLE_DATA_DIR_SEARCH
// Look in current working directory
name = AddSeparator(g_argvPathHint) + filename;
file.open(name.c_str());
if (file.is_open())
return AddSeparator(g_argvPathHint);
#endif
#ifdef CRYPTOPP_DATA_DIR #ifdef CRYPTOPP_DATA_DIR
// Honor CRYPTOPP_DATA_DIR. This is likely an install directory if it is not "./". // Honor CRYPTOPP_DATA_DIR. This is likely an install directory if it is not "./".
name = AddSeparator(CRYPTOPP_DATA_DIR) + filename; name = AddSeparator(CRYPTOPP_DATA_DIR) + filename;