Merge pull request #564 from kiwix/fixHeader

Add iostream header and namespace std
pull/567/head
Kelson 4 years ago committed by GitHub
commit 5709d4d489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -85,20 +85,20 @@ void usage()
<< std::endl; << std::endl;
} }
string loadCustomTemplate (string customIndexPath) { std::string loadCustomTemplate (std::string customIndexPath) {
customIndexPath = kiwix::isRelativePath(customIndexPath) ? customIndexPath = kiwix::isRelativePath(customIndexPath) ?
kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), customIndexPath) : kiwix::computeAbsolutePath(kiwix::getCurrentDirectory(), customIndexPath) :
customIndexPath; customIndexPath;
if (!kiwix::fileReadable(customIndexPath)) { if (!kiwix::fileReadable(customIndexPath)) {
throw runtime_error("No such file exist (or file is not readable) " + customIndexPath); throw std::runtime_error("No such file exist (or file is not readable) " + customIndexPath);
} }
if (kiwix::getMimeTypeForFile(customIndexPath) != "text/html") { if (kiwix::getMimeTypeForFile(customIndexPath) != "text/html") {
throw runtime_error("Invalid File Mime Type " + kiwix::getMimeTypeForFile(customIndexPath)); throw std::runtime_error("Invalid File Mime Type " + kiwix::getMimeTypeForFile(customIndexPath));
} }
string indexTemplateString = kiwix::getFileContent(customIndexPath); std::string indexTemplateString = kiwix::getFileContent(customIndexPath);
if (indexTemplateString.empty()) { if (indexTemplateString.empty()) {
throw runtime_error("Unreadable or empty file " + customIndexPath); throw std::runtime_error("Unreadable or empty file " + customIndexPath);
} }
return indexTemplateString; return indexTemplateString;
} }
@ -189,12 +189,12 @@ int main(int argc, char** argv)
std::string rootLocation = ""; std::string rootLocation = "";
kiwix::Library library; kiwix::Library library;
unsigned int nb_threads = DEFAULT_THREADS; unsigned int nb_threads = DEFAULT_THREADS;
vector<string> zimPathes; std::vector<std::string> zimPathes;
string libraryPath; std::string libraryPath;
string rootPath; std::string rootPath;
string address; std::string address;
string customIndexPath=""; std::string customIndexPath="";
string indexTemplateString=""; std::string indexTemplateString="";
int serverPort = 80; int serverPort = 80;
int daemonFlag [[gnu::unused]] = false; int daemonFlag [[gnu::unused]] = false;
int libraryFlag = false; int libraryFlag = false;
@ -271,16 +271,16 @@ int main(int argc, char** argv)
PPID = atoi(optarg); PPID = atoi(optarg);
break; break;
case 'i': case 'i':
address = string(optarg); address = std::string(optarg);
break; break;
case 't': case 't':
nb_threads = atoi(optarg); nb_threads = atoi(optarg);
break; break;
case 'r': case 'r':
rootLocation = string(optarg); rootLocation = std::string(optarg);
break; break;
case 'c': case 'c':
customIndexPath = string(optarg); customIndexPath = std::string(optarg);
break; break;
case 'M': case 'M':
monitorLibrary = true; monitorLibrary = true;
@ -313,7 +313,7 @@ int main(int argc, char** argv)
/* Setup the library manager and get the list of books */ /* Setup the library manager and get the list of books */
kiwix::Manager manager(&library); kiwix::Manager manager(&library);
vector<string> libraryPaths; std::vector<std::string> libraryPaths;
if (libraryFlag) { if (libraryFlag) {
libraryPaths = kiwix::split(libraryPath, ";"); libraryPaths = kiwix::split(libraryPath, ";");
if ( !reloadLibrary(manager, libraryPaths) ) { if ( !reloadLibrary(manager, libraryPaths) ) {
@ -322,15 +322,15 @@ int main(int argc, char** argv)
/* Check if the library is not empty (or only remote books)*/ /* Check if the library is not empty (or only remote books)*/
if (library.getBookCount(true, false) == 0) { if (library.getBookCount(true, false) == 0) {
cerr << "The XML library file '" << libraryPath std::cerr << "The XML library file '" << libraryPath
<< "' is empty (or has only remote books)." << endl; << "' is empty (or has only remote books)." << std::endl;
} }
} else { } else {
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
for (it = zimPathes.begin(); it != zimPathes.end(); it++) { for (it = zimPathes.begin(); it != zimPathes.end(); it++) {
if (!manager.addBookFromPath(*it, *it, "", false)) { if (!manager.addBookFromPath(*it, *it, "", false)) {
cerr << "Unable to add the ZIM file '" << *it std::cerr << "Unable to add the ZIM file '" << *it
<< "' to the internal library." << endl; << "' to the internal library." << std::endl;
exit(1); exit(1);
} }
} }
@ -410,7 +410,7 @@ int main(int argc, char** argv)
int ret = sysctl(mib, MIBSIZE, &kp, &len, NULL, 0); int ret = sysctl(mib, MIBSIZE, &kp, &len, NULL, 0);
if (ret != -1 && len > 0) { if (ret != -1 && len > 0) {
#else /* Linux & co */ #else /* Linux & co */
string procPath = "/proc/" + std::to_string(PPID); std::string procPath = "/proc/" + std::to_string(PPID);
if (access(procPath.c_str(), F_OK) != -1) { if (access(procPath.c_str(), F_OK) != -1) {
#endif #endif
} else { } else {

@ -26,6 +26,7 @@
#include <kiwix/version.h> #include <kiwix/version.h>
#include <zim/version.h> #include <zim/version.h>
#include <iostream>
void version() void version()
{ {

Loading…
Cancel
Save