mirror of https://github.com/kiwix/libkiwix.git
+ fix to deal with relative path on Windows
This commit is contained in:
parent
4fbf78164a
commit
a1c38f8d74
|
@ -71,7 +71,7 @@ namespace kiwix {
|
||||||
book.indexPathAbsolute = computeAbsolutePath(libraryPath, book.indexPath);
|
book.indexPathAbsolute = computeAbsolutePath(libraryPath, book.indexPath);
|
||||||
else
|
else
|
||||||
book.indexPathAbsolute = book.indexPath;
|
book.indexPathAbsolute = book.indexPath;
|
||||||
|
|
||||||
/* Update the book properties with the new importer */
|
/* Update the book properties with the new importer */
|
||||||
if (libraryVersion.empty() || atoi(libraryVersion.c_str()) < atoi(KIWIX_LIBRARY_VERSION)) {
|
if (libraryVersion.empty() || atoi(libraryVersion.c_str()) < atoi(KIWIX_LIBRARY_VERSION)) {
|
||||||
if (!book.path.empty()) {
|
if (!book.path.empty()) {
|
||||||
|
@ -103,18 +103,19 @@ namespace kiwix {
|
||||||
#endif
|
#endif
|
||||||
string absolutePath = removeLastPathElement(libraryPath, true, false);
|
string absolutePath = removeLastPathElement(libraryPath, true, false);
|
||||||
char *cRelativePath = strdup(relativePath.c_str());
|
char *cRelativePath = strdup(relativePath.c_str());
|
||||||
char *token = strtok(cRelativePath, separator.c_str());
|
char *token = strtok(cRelativePath, "/");
|
||||||
|
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
if (string(token) == "..") {
|
if (string(token) == "..") {
|
||||||
absolutePath = removeLastPathElement(absolutePath, true, false);
|
absolutePath = removeLastPathElement(absolutePath, true, false);
|
||||||
token = strtok(NULL, separator.c_str());
|
token = strtok(NULL, "/");
|
||||||
} else if (token != "." && token != "") {
|
} else if (token != "." && token != "") {
|
||||||
absolutePath += string(token);
|
absolutePath += string(token);
|
||||||
token = strtok(NULL, separator.c_str());
|
token = strtok(NULL, "/");
|
||||||
if (token != NULL)
|
if (token != NULL)
|
||||||
absolutePath += separator;
|
absolutePath += separator;
|
||||||
} else {
|
} else {
|
||||||
token = strtok(NULL, separator.c_str());
|
token = strtok(NULL, "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue