⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _file_module_8hpp-source.html

📁 用c++编写http server的源码库,对socket等网络处理的代码可迅速转为己用.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a name="l00091"></a>00091     <span class="comment">// default constructor and destructor</span><a name="l00092"></a>00092     <a class="code" href="class_file_module.html#89750297878b91a8bff76e3470ea0083">FileModule</a>(<span class="keywordtype">void</span>);<a name="l00093"></a><a class="code" href="class_file_module.html#37cfd16771234e12f91ad2a99510e9f9">00093</a>     <span class="keyword">virtual</span> <a class="code" href="class_file_module.html#37cfd16771234e12f91ad2a99510e9f9">~FileModule</a>() {}<a name="l00094"></a>00094     <a name="l00100"></a>00100     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_file_module.html#e2bb1db0158386d16e5b6a9fb264f64e">setOption</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keyword">const</span> std::string&amp; value);<a name="l00101"></a>00101     <a name="l00103"></a>00103     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_file_module.html#b9f46dabadef14ba1ca3b5698b310106" title="handles requests for FileModule">handleRequest</a>(<a class="code" href="namespacepion.html#3c0f3fad0f449ebd309eaf4872f2b222" title="data type for a HTTP request pointer">pion::HTTPRequestPtr</a>&amp; request,<a name="l00104"></a>00104                                <a class="code" href="namespacepion.html#1858b89656b28c6498ad9efd6b7e9d41" title="data type for a TCPConnection pointer">pion::TCPConnectionPtr</a>&amp; tcp_conn);   <a name="l00105"></a>00105     <a name="l00107"></a>00107     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_file_module.html#19565fca50d8699b17520b0733d76a9b" title="called when the module's server is starting">start</a>(<span class="keywordtype">void</span>);<a name="l00108"></a>00108     <a name="l00110"></a>00110     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_file_module.html#72e5556e073da7eb286dd10f6e693abe" title="called when the module's server is stopping">stop</a>(<span class="keywordtype">void</span>);<a name="l00111"></a>00111     <a name="l00113"></a><a class="code" href="class_file_module.html#d60804754b7b2efa400d70ea1970d33e">00113</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_file_module.html#d60804754b7b2efa400d70ea1970d33e" title="sets the logger to be used">setLogger</a>(<a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">pion::PionLogger</a> log_ptr) { <a class="code" href="class_file_module.html#789b2863d2937993e7152aa02c55f0ac" title="primary logging interface used by this class">m_logger</a> = log_ptr; }<a name="l00114"></a>00114     <a name="l00116"></a><a class="code" href="class_file_module.html#60a20e193d2bd53a5a49289e7f905339">00116</a>     <span class="keyword">inline</span> <a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">pion::PionLogger</a> <a class="code" href="class_file_module.html#60a20e193d2bd53a5a49289e7f905339" title="returns the logger currently in use">getLogger</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> <a class="code" href="class_file_module.html#789b2863d2937993e7152aa02c55f0ac" title="primary logging interface used by this class">m_logger</a>; }<a name="l00117"></a>00117 <a name="l00118"></a>00118     <a name="l00119"></a>00119 <span class="keyword">protected</span>:<a name="l00120"></a>00120 <a name="l00122"></a><a class="code" href="struct_file_module_1_1_disk_file.html">00122</a>     <span class="keyword">struct </span><a class="code" href="struct_file_module_1_1_disk_file.html" title="data type representing files on disk">DiskFile</a> {<a name="l00124"></a><a class="code" href="struct_file_module_1_1_disk_file.html#7d8b2752d7d788108a1aa0c3790c27fd">00124</a>         <a class="code" href="struct_file_module_1_1_disk_file.html#7d8b2752d7d788108a1aa0c3790c27fd" title="constructors for convenience">DiskFile</a>(<span class="keywordtype">void</span>)<a name="l00125"></a>00125             : <a class="code" href="struct_file_module_1_1_disk_file.html#bca608cf97377af55fa929895c9fb469" title="size of the file's content">file_size</a>(0), <a class="code" href="struct_file_module_1_1_disk_file.html#4295e8fe34d30c0cbc6e838bcae3a651" title="timestamp that the cached file was last modified (0 = cache disabled)">last_modified</a>(0) {}<a name="l00126"></a><a class="code" href="struct_file_module_1_1_disk_file.html#bb065fcdc762e3c792458945c9c5354d">00126</a>         <a class="code" href="struct_file_module_1_1_disk_file.html#7d8b2752d7d788108a1aa0c3790c27fd" title="constructors for convenience">DiskFile</a>(<span class="keyword">const</span> boost::filesystem::path&amp; path,<a name="l00127"></a>00127                  <span class="keywordtype">char</span> *content, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> size,<a name="l00128"></a>00128                  std::time_t modified, <span class="keyword">const</span> std::string&amp; mime)<a name="l00129"></a>00129             : <a class="code" href="struct_file_module_1_1_disk_file.html#41a8575deadf1d75d6aaeb76c057300c" title="path to the cached file">file_path</a>(path), <a class="code" href="struct_file_module_1_1_disk_file.html#11122c2b7e3117e02662fb9b597f9a55" title="content of the cached file">file_content</a>(content), <a class="code" href="struct_file_module_1_1_disk_file.html#bca608cf97377af55fa929895c9fb469" title="size of the file's content">file_size</a>(size),<a name="l00130"></a>00130             <a class="code" href="struct_file_module_1_1_disk_file.html#4295e8fe34d30c0cbc6e838bcae3a651" title="timestamp that the cached file was last modified (0 = cache disabled)">last_modified</a>(modified), <a class="code" href="struct_file_module_1_1_disk_file.html#a1d1ffa0623d297951030e8c69a1d749" title="mime type for the cached file">mime_type</a>(mime) {}<a name="l00132"></a>00132         <span class="keywordtype">void</span> <a class="code" href="struct_file_module_1_1_disk_file.html#b60a58a57d7a32adb62b1c0e5d20f0df" title="updates the file_size and last_modified timestamp to disk">update</a>(<span class="keywordtype">void</span>);<a name="l00134"></a>00134         <span class="keywordtype">void</span> <a class="code" href="struct_file_module_1_1_disk_file.html#a726bc66b4d290fe09c1edf02179aae6" title="reads content from disk into file_content buffer">read</a>(<span class="keywordtype">void</span>);<a name="l00140"></a>00140         <span class="keywordtype">bool</span> <a class="code" href="struct_file_module_1_1_disk_file.html#5035f7db79097b1420ff056ac2632ec3">checkUpdated</a>(<span class="keywordtype">void</span>);<a name="l00142"></a><a class="code" href="struct_file_module_1_1_disk_file.html#41a8575deadf1d75d6aaeb76c057300c">00142</a>         boost::filesystem::path     <a class="code" href="struct_file_module_1_1_disk_file.html#41a8575deadf1d75d6aaeb76c057300c" title="path to the cached file">file_path</a>;<a name="l00144"></a><a class="code" href="struct_file_module_1_1_disk_file.html#11122c2b7e3117e02662fb9b597f9a55">00144</a>         boost::shared_array&lt;char&gt;   <a class="code" href="struct_file_module_1_1_disk_file.html#11122c2b7e3117e02662fb9b597f9a55" title="content of the cached file">file_content</a>;<a name="l00146"></a><a class="code" href="struct_file_module_1_1_disk_file.html#bca608cf97377af55fa929895c9fb469">00146</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>               <a class="code" href="struct_file_module_1_1_disk_file.html#bca608cf97377af55fa929895c9fb469" title="size of the file's content">file_size</a>;<a name="l00148"></a><a class="code" href="struct_file_module_1_1_disk_file.html#4295e8fe34d30c0cbc6e838bcae3a651">00148</a>         std::time_t                 <a class="code" href="struct_file_module_1_1_disk_file.html#4295e8fe34d30c0cbc6e838bcae3a651" title="timestamp that the cached file was last modified (0 = cache disabled)">last_modified</a>;<a name="l00150"></a><a class="code" href="struct_file_module_1_1_disk_file.html#cc967ce35332fea0dd00f6ab9a12df9a">00150</a>         std::string                 <a class="code" href="struct_file_module_1_1_disk_file.html#cc967ce35332fea0dd00f6ab9a12df9a" title="timestamp that the cached file was last modified (string format)">last_modified_string</a>;<a name="l00152"></a><a class="code" href="struct_file_module_1_1_disk_file.html#a1d1ffa0623d297951030e8c69a1d749">00152</a>         std::string                 <a class="code" href="struct_file_module_1_1_disk_file.html#a1d1ffa0623d297951030e8c69a1d749" title="mime type for the cached file">mime_type</a>;<a name="l00153"></a>00153     };<a name="l00154"></a>00154     <a name="l00156"></a><a class="code" href="class_file_module.html#65973259d5a984b3933d8ea7aa97e5f1">00156</a>     <span class="keyword">typedef</span> PION_HASH_MAP&lt;std::string, DiskFile, boost::hash&lt;std::string&gt; &gt; <a class="code" href="class_file_module.html#65973259d5a984b3933d8ea7aa97e5f1" title="data type for map of file names to cache entries">CacheMap</a>;<a name="l00157"></a>00157     <a name="l00159"></a><a class="code" href="class_file_module.html#2159dcd07ecffdf2aa1ee93d697308d8">00159</a>     <span class="keyword">typedef</span> PION_HASH_MAP&lt;std::string, std::string, boost::hash&lt;std::string&gt; &gt;  <a class="code" href="class_file_module.html#2159dcd07ecffdf2aa1ee93d697308d8" title="data type for map of file extensions to MIME types">MIMETypeMap</a>;<a name="l00160"></a>00160 <a name="l00161"></a>00161     <a name="l00167"></a>00167     <span class="keywordtype">void</span> <a class="code" href="class_file_module.html#1ad8c01c7d0253b5da3068d574169d82">scanDirectory</a>(<span class="keyword">const</span> boost::filesystem::path&amp; dir_path);<a name="l00168"></a>00168     <a name="l00179"></a>00179     std::pair&lt;CacheMap::iterator, bool&gt;<a name="l00180"></a>00180         <a class="code" href="class_file_module.html#5df44719239d16aedf792fe5c9a19e5a">addCacheEntry</a>(<span class="keyword">const</span> std::string&amp; relative_path,<a name="l00181"></a>00181                       <span class="keyword">const</span> boost::filesystem::path&amp; file_path,<a name="l00182"></a>00182                       <span class="keyword">const</span> <span class="keywordtype">bool</span> placeholder);<a name="l00183"></a>00183 <a name="l00190"></a>00190     <span class="keyword">static</span> std::string <a class="code" href="class_file_module.html#8bd10d069624bf87d81343120aebe723">findMIMEType</a>(<span class="keyword">const</span> std::string&amp; file_name);<a name="l00191"></a>00191 <a name="l00192"></a>00192     <a name="l00194"></a><a class="code" href="class_file_module.html#789b2863d2937993e7152aa02c55f0ac">00194</a>     <a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">pion::PionLogger</a>            <a class="code" href="class_file_module.html#789b2863d2937993e7152aa02c55f0ac" title="primary logging interface used by this class">m_logger</a>;<a name="l00195"></a>00195     <a name="l00196"></a>00196     <a name="l00197"></a>00197 <span class="keyword">private</span>:<a name="l00198"></a>00198     <a name="l00200"></a>00200     <span class="keyword">static</span> <span class="keywordtype">void</span> createMIMETypes(<span class="keywordtype">void</span>);<a name="l00201"></a>00201     <a name="l00202"></a>00202     <a name="l00204"></a>00204     <span class="keyword">static</span> <span class="keyword">const</span> std::string    DEFAULT_MIME_TYPE;<a name="l00205"></a>00205     <a name="l00207"></a>00207     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>   DEFAULT_CACHE_SETTING;<a name="l00208"></a>00208 <a name="l00210"></a>00210     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>   DEFAULT_SCAN_SETTING;<a name="l00211"></a>00211 <a name="l00213"></a>00213     <span class="keyword">static</span> boost::once_flag     m_mime_types_init_flag;<a name="l00214"></a>00214     <a name="l00216"></a>00216     <span class="keyword">static</span> <a class="code" href="class_file_module.html#2159dcd07ecffdf2aa1ee93d697308d8" title="data type for map of file extensions to MIME types">MIMETypeMap</a> *        m_mime_types_ptr;<a name="l00217"></a>00217     <a name="l00218"></a>00218     <a name="l00220"></a>00220     boost::filesystem::path     m_directory;<a name="l00221"></a>00221     <a name="l00223"></a>00223     boost::filesystem::path     m_file;<a name="l00224"></a>00224     <a name="l00226"></a>00226     <a class="code" href="class_file_module.html#65973259d5a984b3933d8ea7aa97e5f1" title="data type for map of file names to cache entries">CacheMap</a>                    m_cache_map;<a name="l00227"></a>00227     <a name="l00229"></a>00229     boost::mutex                m_cache_mutex;<a name="l00230"></a>00230     <a name="l00237"></a>00237     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                m_cache_setting;<a name="l00238"></a>00238 <a name="l00246"></a>00246     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                m_scan_setting;<a name="l00247"></a>00247 };<a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 19 13:29:22 2007 for libpion by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -