23 #include <core/exceptions/system.h> 25 #include <utils/system/filetype.h> 26 #include <webview/file_reply.h> 46 const std::string &content_type)
49 if (access(filename.c_str(), R_OK) != 0 || ((file_ = fopen(filename.c_str(),
"r")) == NULL)) {
53 determine_file_size();
55 if (content_type.empty()) {
68 if (access(filename, R_OK) != 0 || ((file_ = fopen(filename,
"r")) == NULL)) {
72 determine_file_size();
84 fseek(file_, 0, SEEK_SET);
85 determine_file_size();
90 fseek(file_, 0, SEEK_SET);
102 DynamicFileWebReply::determine_file_size()
105 fstat(fileno(file_), &sbuf);
107 if (S_ISDIR(sbuf.st_mode)) {
110 size_ = sbuf.st_size;
122 if ((fseek(file_, pos, SEEK_SET) == -1) || feof(file_)) {
125 return fread(buffer, 1, buf_max_size, file_);
File could not be opened.
virtual size_t size()
Total size of the web reply.
DynamicFileWebReply(const std::string &filename, const std::string &content_type="")
Constructor.
Fawkes library namespace.
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.
void add_header(const std::string &header, const std::string &content)
Add a HTTP header.