mirror of https://github.com/kiwix/libkiwix.git
+ better factorisation of the code (moved from manager.cpp to pathTools.cpp) -> creation of functions getFileSize() and getFileSizeAsString()
This commit is contained in:
parent
9182f4e529
commit
98bf706297
|
@ -236,12 +236,7 @@ namespace kiwix {
|
||||||
mediaCountStream << reader.getMediaCount();
|
mediaCountStream << reader.getMediaCount();
|
||||||
book.mediaCount = mediaCountStream.str();
|
book.mediaCount = mediaCountStream.str();
|
||||||
|
|
||||||
struct stat filestatus;
|
book.size = getFileSizeAsString(path);
|
||||||
stat( path.c_str(), &filestatus );
|
|
||||||
unsigned int size = filestatus.st_size / 1024;
|
|
||||||
char csize[42];
|
|
||||||
sprintf (csize, "%u", size);
|
|
||||||
book.size = csize;
|
|
||||||
|
|
||||||
string favicon;
|
string favicon;
|
||||||
string faviconMimeType;
|
string faviconMimeType;
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
|
||||||
|
|
|
@ -71,3 +71,14 @@ string removeLastPathElement(const string path, const bool removePreSeparator, c
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int getFileSize(const string &path) {
|
||||||
|
struct stat filestatus;
|
||||||
|
stat(path.c_str(), &filestatus);
|
||||||
|
return filestatus.st_size / 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
string getFileSizeAsString(const string &path) {
|
||||||
|
char csize[42];
|
||||||
|
sprintf(csize, "%u", getFileSize(path));
|
||||||
|
return csize;
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -29,5 +33,7 @@ bool isRelativePath(const string &path);
|
||||||
string computeAbsolutePath(const string libraryPath, const string relativePath);
|
string computeAbsolutePath(const string libraryPath, const string relativePath);
|
||||||
string removeLastPathElement(const string path, const bool removePreSeparator = false,
|
string removeLastPathElement(const string path, const bool removePreSeparator = false,
|
||||||
const bool removePostSeparator = false);
|
const bool removePostSeparator = false);
|
||||||
|
unsigned int getFileSize(const string &path);
|
||||||
|
string getFileSizeAsString(const string &path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue