+ better deal with accented paths

This commit is contained in:
kelson42 2011-09-05 18:53:02 +00:00
parent 1c2037e5fa
commit 6959085e3c
4 changed files with 17 additions and 3 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -23,5 +23,6 @@
#include "nsStringAPI.h"
const char *nsStringToCString(const nsAString &path);
const char *nsStringToUTF8(const nsAString &str);
#endif