From a1c38f8d7415ac8cbea93ac81517cf751d9fbbe5 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Sun, 4 Sep 2011 13:48:26 +0000 Subject: [PATCH] + fix to deal with relative path on Windows --- src/common/kiwix/manager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/kiwix/manager.cpp b/src/common/kiwix/manager.cpp index aba8df98a..1f136174d 100644 --- a/src/common/kiwix/manager.cpp +++ b/src/common/kiwix/manager.cpp @@ -71,7 +71,7 @@ namespace kiwix { book.indexPathAbsolute = computeAbsolutePath(libraryPath, book.indexPath); else book.indexPathAbsolute = book.indexPath; - + /* Update the book properties with the new importer */ if (libraryVersion.empty() || atoi(libraryVersion.c_str()) < atoi(KIWIX_LIBRARY_VERSION)) { if (!book.path.empty()) { @@ -103,18 +103,19 @@ namespace kiwix { #endif string absolutePath = removeLastPathElement(libraryPath, true, false); char *cRelativePath = strdup(relativePath.c_str()); - char *token = strtok(cRelativePath, separator.c_str()); + char *token = strtok(cRelativePath, "/"); + while (token != NULL) { if (string(token) == "..") { absolutePath = removeLastPathElement(absolutePath, true, false); - token = strtok(NULL, separator.c_str()); + token = strtok(NULL, "/"); } else if (token != "." && token != "") { absolutePath += string(token); - token = strtok(NULL, separator.c_str()); + token = strtok(NULL, "/"); if (token != NULL) absolutePath += separator; } else { - token = strtok(NULL, separator.c_str()); + token = strtok(NULL, "/"); } }