mirror of https://github.com/kiwix/libkiwix.git
commit
0f99c1ad20
|
@ -69,27 +69,13 @@ class Manager
|
||||||
/**
|
/**
|
||||||
* Read a `library.xml` and add book in the file to the library.
|
* 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
|
* @param readOnly Set if the libray path could be overwritten latter with
|
||||||
* updated content.
|
* updated content.
|
||||||
* @return True if file has been properly parsed.
|
* @return True if file has been properly parsed.
|
||||||
*/
|
*/
|
||||||
bool readFile(const std::string& path, const bool readOnly = true);
|
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.
|
* Load a library content store in the string.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string WideToUtf8(const std::wstring& wstr);
|
||||||
|
std::wstring Utf8ToWide(const std::string& str);
|
||||||
|
#endif
|
||||||
bool isRelativePath(const std::string& path);
|
bool isRelativePath(const std::string& path);
|
||||||
std::string computeAbsolutePath(const std::string& path, const std::string& relativePath);
|
std::string computeAbsolutePath(const std::string& path, const std::string& relativePath);
|
||||||
std::string computeRelativePath(const std::string& path, const std::string& absolutePath);
|
std::string computeRelativePath(const std::string& path, const std::string& absolutePath);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "manager.h"
|
#include "manager.h"
|
||||||
|
|
||||||
|
#include "tools/pathTools.h"
|
||||||
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
|
||||||
namespace kiwix
|
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)
|
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;
|
bool retVal = true;
|
||||||
pugi::xml_document doc;
|
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) {
|
if (result) {
|
||||||
this->parseXmlDom(doc, readOnly, UTF8Path);
|
this->parseXmlDom(doc, readOnly, path);
|
||||||
} else {
|
} else {
|
||||||
retVal = false;
|
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
|
* able to know where to save the library if new content are
|
||||||
* available */
|
* available */
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
this->writableLibraryPath = UTF8Path;
|
this->writableLibraryPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
Loading…
Reference in New Issue