forked from soutade/libgourou
Add new default ADEPT directories : /home/<user>/.config/adept and $ADEPT_DIR environment variable
This commit is contained in:
@@ -201,6 +201,8 @@ static void usage(const char* cmd)
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "Device file, activation file and device key file are optionals. If not set, they are looked into :" << std::endl;
|
||||
std::cout << " * $ADEPT_DIR environment variable" << std::endl;
|
||||
std::cout << " * /home/<user>/.config/adept" << std::endl;
|
||||
std::cout << " * Current directory" << std::endl;
|
||||
std::cout << " * .adept" << std::endl;
|
||||
std::cout << " * adobe-digital-editions directory" << std::endl;
|
||||
|
@@ -230,7 +230,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (!_outputDir || _outputDir[0] == 0)
|
||||
{
|
||||
outputDir = strdup(abspath(DEFAULT_ADEPT_DIR));
|
||||
outputDir = strdup(abspath(gourou::DRMProcessor::getDefaultAdeptDir().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -348,6 +348,8 @@ static void usage(const char* cmd)
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "ADEPT directory is optional. If not set, it's looked into :" << std::endl;
|
||||
std::cout << " * $ADEPT_DIR environment variable" << std::endl;
|
||||
std::cout << " * /home/<user>/.config/adept" << std::endl;
|
||||
std::cout << " * Current directory" << std::endl;
|
||||
std::cout << " * .adept" << std::endl;
|
||||
std::cout << " * adobe-digital-editions directory" << std::endl;
|
||||
|
@@ -158,6 +158,8 @@ static void usage(const char* cmd)
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "Device file, activation file and device key file are optionals. If not set, they are looked into :" << std::endl;
|
||||
std::cout << " * $ADEPT_DIR environment variable" << std::endl;
|
||||
std::cout << " * /home/<user>/.config/adept" << std::endl;
|
||||
std::cout << " * Current directory" << std::endl;
|
||||
std::cout << " * .adept" << std::endl;
|
||||
std::cout << " * adobe-digital-editions directory" << std::endl;
|
||||
|
@@ -61,6 +61,20 @@ bool fileExists(const char* filename)
|
||||
|
||||
const char* findFile(const char* filename, bool inDefaultDirs)
|
||||
{
|
||||
std::string path;
|
||||
|
||||
const char* adeptDir = getenv("ADEPT_DIR");
|
||||
if (adeptDir && adeptDir[0])
|
||||
{
|
||||
path = adeptDir + std::string("/") + filename;
|
||||
if (fileExists(path.c_str()))
|
||||
return strdup(path.c_str());
|
||||
}
|
||||
|
||||
path = gourou::DRMProcessor::getDefaultAdeptDir() + filename;
|
||||
if (fileExists(path.c_str()))
|
||||
return strdup(path.c_str());
|
||||
|
||||
if (fileExists(filename))
|
||||
return strdup(filename);
|
||||
|
||||
@@ -68,7 +82,7 @@ const char* findFile(const char* filename, bool inDefaultDirs)
|
||||
|
||||
for (int i=0; i<(int)ARRAY_SIZE(defaultDirs); i++)
|
||||
{
|
||||
std::string path = std::string(defaultDirs[i]) + filename;
|
||||
path = std::string(defaultDirs[i]) + filename;
|
||||
if (fileExists(path.c_str()))
|
||||
return strdup(path.c_str());
|
||||
}
|
||||
|
Reference in New Issue
Block a user