23 #include <webview/file_reply.h>
25 #include <core/exceptions/system.h>
26 #include <utils/system/filetype.h>
47 DynamicFileWebReply::DynamicFileWebReply(
const char *filename)
50 if (access(filename, R_OK) != 0 || ((__file = fopen(filename,
"r")) == NULL)) {
55 fstat(fileno(__file), &sbuf);
57 if ( S_ISDIR(sbuf.st_mode) ) {
60 __size = sbuf.st_size;
80 if ( (fseek(__file, pos, SEEK_SET) == -1) || feof(__file) ) {
83 return fread(buffer, 1, buf_max_size, __file);
File could not be opened.
virtual size_t size()
Total size of the web reply.
Fawkes library namespace.
void add_header(std::string header, std::string content)
Add a HTTP header.
virtual ~DynamicFileWebReply()
Destructor.
std::string mimetype_file(const char *filename)
Get mime-type of file.
Base class for exceptions in Fawkes.
virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size)
Get data of next chunk.