Fawkes API  Fawkes Development Version
file_reply.h
1 
2 /***************************************************************************
3  * file_reply.h - Web request file reply
4  *
5  * Created: Thu Oct 23 13:47:33 2008
6  * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _LIBS_WEBVIEW_FILE_REPLY_H_
24 #define _LIBS_WEBVIEW_FILE_REPLY_H_
25 
26 #include <webview/reply.h>
27 
28 #include <cstdio>
29 
30 namespace fawkes {
31 
32 class DynamicFileWebReply : public DynamicWebReply
33 {
34 public:
35  DynamicFileWebReply(const std::string &filename, const std::string &content_type = "");
36  DynamicFileWebReply(const char *filename);
37  DynamicFileWebReply(FILE *file, bool close_when_done = true);
38  virtual ~DynamicFileWebReply();
39 
40  virtual size_t size();
41  virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size);
42 
43 private:
44  void determine_file_size();
45 
46 private:
47  FILE * file_;
48  size_t size_;
49  bool close_when_done_;
50 };
51 
52 } // end namespace fawkes
53 
54 #endif
fawkes::DynamicFileWebReply::DynamicFileWebReply
DynamicFileWebReply(const std::string &filename, const std::string &content_type="")
Constructor.
Definition: file_reply.cpp:49
fawkes::DynamicFileWebReply::size
virtual size_t size()
Definition: file_reply.cpp:118
fawkes::DynamicFileWebReply::~DynamicFileWebReply
virtual ~DynamicFileWebReply()
Destructor.
Definition: file_reply.cpp:98
fawkes
fawkes::DynamicFileWebReply::next_chunk
virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size)
Definition: file_reply.cpp:124