mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
Ensure the book's path
is absolute.
We must use absolute path whenever possible. Relative path has sense only related to the "interaction" with the user (current directory, library location, ...).
This commit is contained in:
@ -208,12 +208,16 @@ bool Manager::addBookFromPath(const std::string& pathToOpen,
|
||||
|
||||
bool Manager::readBookFromPath(const std::string& path, kiwix::Book* book)
|
||||
{
|
||||
std::string tmp_path = path;
|
||||
if (isRelativePath(path)) {
|
||||
tmp_path = computeAbsolutePath(getCurrentDirectory(), path);
|
||||
}
|
||||
try {
|
||||
kiwix::Reader reader(path);
|
||||
kiwix::Reader reader(tmp_path);
|
||||
book->update(reader);
|
||||
book->setPathValid(true);
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Invalid " << path << " : " << e.what() << std::endl;
|
||||
std::cerr << "Invalid " << tmp_path << " : " << e.what() << std::endl;
|
||||
book->setPathValid(false);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user