mirror of https://github.com/kiwix/libkiwix.git
+ better deal with accented paths
This commit is contained in:
parent
1c2037e5fa
commit
6959085e3c
|
@ -251,10 +251,10 @@ namespace kiwix {
|
|||
return library.current;
|
||||
}
|
||||
|
||||
bool Manager::addBookFromPath(const string path, const string url, const bool checkMetaData) {
|
||||
bool Manager::addBookFromPath(const string pathToOpen, const string pathToSave, const string url, const bool checkMetaData) {
|
||||
kiwix::Book book;
|
||||
|
||||
if (this->readBookFromPath(path, book)) {
|
||||
if (this->readBookFromPath(pathToOpen, book)) {
|
||||
|
||||
if (!checkMetaData ||
|
||||
checkMetaData && !book.title.empty() && !book.language.empty() && !book.date.empty()) {
|
||||
|
@ -262,6 +262,11 @@ namespace kiwix {
|
|||
library.addBook(book);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pathToSave.empty() && pathToSave != pathToOpen) {
|
||||
book.path = pathToSave;
|
||||
book.pathAbsolute = pathToSave;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace kiwix {
|
|||
bool setBookIndex(const string id, const string path, const supportedIndexType type);
|
||||
bool setBookPath(const string id, const string path);
|
||||
string getCurrentBookId();
|
||||
bool addBookFromPath(const string path, const string url = "", const bool checkMetaData = false);
|
||||
bool addBookFromPath(const string pathToOpen, const string pathToSave = "", const string url = "", const bool checkMetaData = false);
|
||||
Library cloneLibrary();
|
||||
bool getBookById(const string id, Book &book);
|
||||
unsigned int getBookCount(const bool localBooks, const bool remoteBooks);
|
||||
|
|
|
@ -32,3 +32,11 @@ const char *nsStringToCString(const nsAString &str) {
|
|||
NS_CStringGetData(tmpStr, &cStr);
|
||||
return cStr;
|
||||
}
|
||||
|
||||
const char *nsStringToUTF8(const nsAString &str) {
|
||||
const char *cStr;
|
||||
nsCString tmpStr;
|
||||
CopyUTF16toUTF8(str, tmpStr);
|
||||
NS_CStringGetData(tmpStr, &cStr);
|
||||
return cStr;
|
||||
}
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
#include "nsStringAPI.h"
|
||||
|
||||
const char *nsStringToCString(const nsAString &path);
|
||||
const char *nsStringToUTF8(const nsAString &str);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue