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;
|
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;
|
kiwix::Book book;
|
||||||
|
|
||||||
if (this->readBookFromPath(path, book)) {
|
if (this->readBookFromPath(pathToOpen, book)) {
|
||||||
|
|
||||||
if (!checkMetaData ||
|
if (!checkMetaData ||
|
||||||
checkMetaData && !book.title.empty() && !book.language.empty() && !book.date.empty()) {
|
checkMetaData && !book.title.empty() && !book.language.empty() && !book.date.empty()) {
|
||||||
|
@ -262,6 +262,11 @@ namespace kiwix {
|
||||||
library.addBook(book);
|
library.addBook(book);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pathToSave.empty() && pathToSave != pathToOpen) {
|
||||||
|
book.path = pathToSave;
|
||||||
|
book.pathAbsolute = pathToSave;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace kiwix {
|
||||||
bool setBookIndex(const string id, const string path, const supportedIndexType type);
|
bool setBookIndex(const string id, const string path, const supportedIndexType type);
|
||||||
bool setBookPath(const string id, const string path);
|
bool setBookPath(const string id, const string path);
|
||||||
string getCurrentBookId();
|
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();
|
Library cloneLibrary();
|
||||||
bool getBookById(const string id, Book &book);
|
bool getBookById(const string id, Book &book);
|
||||||
unsigned int getBookCount(const bool localBooks, const bool remoteBooks);
|
unsigned int getBookCount(const bool localBooks, const bool remoteBooks);
|
||||||
|
|
|
@ -32,3 +32,11 @@ const char *nsStringToCString(const nsAString &str) {
|
||||||
NS_CStringGetData(tmpStr, &cStr);
|
NS_CStringGetData(tmpStr, &cStr);
|
||||||
return 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"
|
#include "nsStringAPI.h"
|
||||||
|
|
||||||
const char *nsStringToCString(const nsAString &path);
|
const char *nsStringToCString(const nsAString &path);
|
||||||
|
const char *nsStringToUTF8(const nsAString &str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue