diff --git a/include/manager.h b/include/manager.h index 843af32d9..13087ca70 100644 --- a/include/manager.h +++ b/include/manager.h @@ -69,27 +69,13 @@ class Manager /** * Read a `library.xml` and add book in the file to the library. * - * @param path The path to the `library.xml`. + * @param path The (utf8) path to the `library.xml`. * @param readOnly Set if the libray path could be overwritten latter with * updated content. * @return True if file has been properly parsed. */ bool readFile(const std::string& path, const bool readOnly = true); - /** - * Read a `library.xml` and add book in the file to the library. - * - * @param nativePath The path of the `library.xml` - * @param UTF8Path The utf8 version (?) of the path. Also the path where the - * library will be writen i readOnly is False. - * @param readOnly Set if the libray path could be overwritten latter with - * updated content. - * @return True if file has been properly parsed. - */ - bool readFile(const std::string& nativePath, - const std::string& UTF8Path, - const bool readOnly = true); - /** * Load a library content store in the string. * diff --git a/include/tools/pathTools.h b/include/tools/pathTools.h index 19c843321..37ab6fd2b 100644 --- a/include/tools/pathTools.h +++ b/include/tools/pathTools.h @@ -22,6 +22,10 @@ #include +#ifdef _WIN32 +std::string WideToUtf8(const std::wstring& wstr); +std::wstring Utf8ToWide(const std::string& str); +#endif bool isRelativePath(const std::string& path); std::string computeAbsolutePath(const std::string& path, const std::string& relativePath); std::string computeRelativePath(const std::string& path, const std::string& absolutePath); diff --git a/src/manager.cpp b/src/manager.cpp index 7ff386d7c..cf2534856 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -19,6 +19,8 @@ #include "manager.h" +#include "tools/pathTools.h" + #include namespace kiwix @@ -135,20 +137,18 @@ bool Manager::readOpds(const std::string& content, const std::string& urlHost) } bool Manager::readFile(const std::string& path, const bool readOnly) -{ - return this->readFile(path, path, readOnly); -} - -bool Manager::readFile(const std::string& nativePath, - const std::string& UTF8Path, - const bool readOnly) { bool retVal = true; pugi::xml_document doc; - pugi::xml_parse_result result = doc.load_file(nativePath.c_str()); + +#ifdef _WIN32 + pugi::xml_parse_result result = doc.load_file(Utf8ToWide(path).c_str()); +#else + pugi::xml_parse_result result = doc.load_file(path.c_str()); +#endif if (result) { - this->parseXmlDom(doc, readOnly, UTF8Path); + this->parseXmlDom(doc, readOnly, path); } else { retVal = false; } @@ -157,7 +157,7 @@ bool Manager::readFile(const std::string& nativePath, * able to know where to save the library if new content are * available */ if (!readOnly) { - this->writableLibraryPath = UTF8Path; + this->writableLibraryPath = path; } return retVal;