This repository has been archived on 2026-02-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Livox-SDK/docs/file__helper_8h_source.html
T
2019-04-11 23:07:00 +08:00

138 lines
42 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Livox SDK API: sdk_core/include/third_party/spdlog/spdlog/details/file_helper.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="1.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Livox SDK API
&#160;<span id="projectnumber">v1.0.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('file__helper_8h_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">file_helper.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="file__helper_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment">// Copyright(c) 2015 Gabi Melman.</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment">// Distributed under the MIT License (http://opensource.org/licenses/MIT)</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment">// Helper class for file sinks.</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment">// When failing to open a file, retry several times(5) with a delay interval(10 ms).</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment">// Throw spdlog_ex exception on errors.</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="log__msg_8h.html">spdlog/details/log_msg.h</a>&quot;</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="os_8h.html">spdlog/details/os.h</a>&quot;</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;</div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="preprocessor">#include &lt;cerrno&gt;</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="preprocessor">#include &lt;chrono&gt;</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="preprocessor">#include &lt;cstdio&gt;</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;<span class="preprocessor">#include &lt;thread&gt;</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="preprocessor">#include &lt;tuple&gt;</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacespdlog.html">spdlog</a> {</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="keyword">namespace </span>details {</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html"> 25</a></span>&#160;<span class="keyword">class </span><a class="code" href="classspdlog_1_1details_1_1file__helper.html">file_helper</a></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;{</div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a22be952a421d866566eed3a5ce201144"> 29</a></span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a22be952a421d866566eed3a5ce201144">open_tries</a> = 5;</div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#aea72ea8d655bb11f19dbe48477e6c8b3"> 30</a></span>&#160; <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#aea72ea8d655bb11f19dbe48477e6c8b3">open_interval</a> = 10;</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; <span class="keyword">explicit</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#aa11a5129c9d7492638a68d849d66d47d">file_helper</a>() = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#aa11a5129c9d7492638a68d849d66d47d">file_helper</a>(<span class="keyword">const</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html">file_helper</a> &amp;) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; <a class="code" href="classspdlog_1_1details_1_1file__helper.html">file_helper</a> &amp;<a class="code" href="classspdlog_1_1details_1_1file__helper.html#a7c7314360e404efa02326feb7aa98442">operator=</a>(<span class="keyword">const</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html">file_helper</a> &amp;) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#aad84ef5f999c2721a0a8ad36ce641e8c"> 37</a></span>&#160; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#aad84ef5f999c2721a0a8ad36ce641e8c">~file_helper</a>()</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; {</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a6a6d7a75014ae880857b4fe4fd01dc7a">close</a>();</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160; }</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a8612066fd098080cc60e3aefed6a6085"> 42</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a8612066fd098080cc60e3aefed6a6085">open</a>(<span class="keyword">const</span> <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">filename_t</a> &amp;fname, <span class="keywordtype">bool</span> truncate = <span class="keyword">false</span>)</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; {</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a6a6d7a75014ae880857b4fe4fd01dc7a">close</a>();</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="keyword">auto</span> *mode = truncate ? <a class="code" href="os_8h.html#a63d60ea1c1a925d3db13864d37bd2da2">SPDLOG_FILENAME_T</a>(<span class="stringliteral">&quot;wb&quot;</span>) : <a class="code" href="os_8h.html#a63d60ea1c1a925d3db13864d37bd2da2">SPDLOG_FILENAME_T</a>(<span class="stringliteral">&quot;ab&quot;</span>);</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; _filename = fname;</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tries = 0; tries &lt; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a22be952a421d866566eed3a5ce201144">open_tries</a>; ++tries)</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; {</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <span class="keywordflow">if</span> (!<a class="code" href="namespacespdlog_1_1details_1_1os.html#af2d11a0b892e2f0cb3c6beba4c659a47">os::fopen_s</a>(&amp;fd_, fname, mode))</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; {</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="keywordflow">return</span>;</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; }</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; <a class="code" href="namespacespdlog_1_1details_1_1os.html#a56a474fcf965264674346ffdefac0759">details::os::sleep_for_millis</a>(<a class="code" href="classspdlog_1_1details_1_1file__helper.html#aea72ea8d655bb11f19dbe48477e6c8b3">open_interval</a>);</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; }</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160;</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <span class="keywordflow">throw</span> <a class="code" href="classspdlog_1_1spdlog__ex.html">spdlog_ex</a>(<span class="stringliteral">&quot;Failed opening file &quot;</span> + <a class="code" href="namespacespdlog_1_1details_1_1os.html#ac7c0d6af1f3f652f23e57f057217b9a7">os::filename_to_str</a>(_filename) + <span class="stringliteral">&quot; for writing&quot;</span>, errno);</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; }</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;</div><div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a21c688da7f241c53871b462c3a5c2c94"> 60</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a21c688da7f241c53871b462c3a5c2c94">reopen</a>(<span class="keywordtype">bool</span> truncate)</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; {</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; <span class="keywordflow">if</span> (_filename.empty())</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; {</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="keywordflow">throw</span> <a class="code" href="classspdlog_1_1spdlog__ex.html">spdlog_ex</a>(<span class="stringliteral">&quot;Failed re opening file - was not opened before&quot;</span>);</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; }</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a8612066fd098080cc60e3aefed6a6085">open</a>(_filename, truncate);</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; }</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160;</div><div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a1a75f29ec0c13d9fbc269bcd8378b18b"> 69</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a1a75f29ec0c13d9fbc269bcd8378b18b">flush</a>()</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; {</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; std::fflush(fd_);</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; }</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160;</div><div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a6a6d7a75014ae880857b4fe4fd01dc7a"> 74</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a6a6d7a75014ae880857b4fe4fd01dc7a">close</a>()</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; {</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <span class="keywordflow">if</span> (fd_ != <span class="keyword">nullptr</span>)</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; {</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; std::fclose(fd_);</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; fd_ = <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; }</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; }</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160;</div><div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a51eb58a2d46f1896f3ab7b9d323d97ae"> 83</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a51eb58a2d46f1896f3ab7b9d323d97ae">write</a>(<span class="keyword">const</span> <a class="code" href="classfmt_1_1v5_1_1basic__memory__buffer.html">fmt::memory_buffer</a> &amp;buf)</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; {</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; <span class="keywordtype">size_t</span> msg_size = buf.<a class="code" href="classfmt_1_1v5_1_1internal_1_1basic__buffer.html#ac4761deba75a7238ae29243b159b9943">size</a>();</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; <span class="keyword">auto</span> <a class="code" href="namespacefmt_1_1v5_1_1internal.html#ac62a332ee64650f2ebe0e8095fa8e7c0">data</a> = buf.<a class="code" href="classfmt_1_1v5_1_1internal_1_1basic__buffer.html#a384f1304da6ce18c4713368327354479">data</a>();</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; <span class="keywordflow">if</span> (std::fwrite(<a class="code" href="namespacefmt_1_1v5_1_1internal.html#ac62a332ee64650f2ebe0e8095fa8e7c0">data</a>, 1, msg_size, fd_) != msg_size)</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; {</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; <span class="keywordflow">throw</span> <a class="code" href="classspdlog_1_1spdlog__ex.html">spdlog_ex</a>(<span class="stringliteral">&quot;Failed writing to file &quot;</span> + <a class="code" href="namespacespdlog_1_1details_1_1os.html#ac7c0d6af1f3f652f23e57f057217b9a7">os::filename_to_str</a>(_filename), errno);</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; }</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; }</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#ae945d9701134218c2d0558958e9d1cf2"> 93</a></span>&#160; <span class="keywordtype">size_t</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#ae945d9701134218c2d0558958e9d1cf2">size</a>()<span class="keyword"> const</span></div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160;<span class="keyword"> </span>{</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; <span class="keywordflow">if</span> (fd_ == <span class="keyword">nullptr</span>)</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; {</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <span class="keywordflow">throw</span> <a class="code" href="classspdlog_1_1spdlog__ex.html">spdlog_ex</a>(<span class="stringliteral">&quot;Cannot use size() on closed file &quot;</span> + <a class="code" href="namespacespdlog_1_1details_1_1os.html#ac7c0d6af1f3f652f23e57f057217b9a7">os::filename_to_str</a>(_filename));</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; }</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="keywordflow">return</span> <a class="code" href="namespacespdlog_1_1details_1_1os.html#a6d2fb5a293e8515f651288992d5443cc">os::filesize</a>(fd_);</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; }</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a76610058a1769b25bd6ed52a1443b552"> 102</a></span>&#160; <span class="keyword">const</span> <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">filename_t</a> &amp;<a class="code" href="classspdlog_1_1details_1_1file__helper.html#a76610058a1769b25bd6ed52a1443b552">filename</a>()<span class="keyword"> const</span></div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160;<span class="keyword"> </span>{</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; <span class="keywordflow">return</span> _filename;</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160; }</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160;</div><div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a8c5f69588e8a54f436c3565317c233bd"> 107</a></span>&#160; <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a8c5f69588e8a54f436c3565317c233bd">file_exists</a>(<span class="keyword">const</span> <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">filename_t</a> &amp;fname)</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160; {</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; <span class="keywordflow">return</span> <a class="code" href="namespacespdlog_1_1details_1_1os.html#afd466bafef75b9792e0ca62e7fdd8dc1">os::file_exists</a>(fname);</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; }</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160;</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; <span class="comment">//</span></div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; <span class="comment">// return file path and its extension:</span></div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; <span class="comment">//</span></div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; <span class="comment">// &quot;mylog.txt&quot; =&gt; (&quot;mylog&quot;, &quot;.txt&quot;)</span></div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; <span class="comment">// &quot;mylog&quot; =&gt; (&quot;mylog&quot;, &quot;&quot;)</span></div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; <span class="comment">// &quot;mylog.&quot; =&gt; (&quot;mylog.&quot;, &quot;&quot;)</span></div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; <span class="comment">// &quot;/dir1/dir2/mylog.txt&quot; =&gt; (&quot;/dir1/dir2/mylog&quot;, &quot;.txt&quot;)</span></div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; <span class="comment">//</span></div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; <span class="comment">// the starting dot in filenames is ignored (hidden files):</span></div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; <span class="comment">//</span></div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; <span class="comment">// &quot;.mylog&quot; =&gt; (&quot;.mylog&quot;. &quot;&quot;)</span></div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; <span class="comment">// &quot;my_folder/.mylog&quot; =&gt; (&quot;my_folder/.mylog&quot;, &quot;&quot;)</span></div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; <span class="comment">// &quot;my_folder/.mylog.txt&quot; =&gt; (&quot;my_folder/.mylog&quot;, &quot;.txt&quot;)</span></div><div class="line"><a name="l00125"></a><span class="lineno"><a class="line" href="classspdlog_1_1details_1_1file__helper.html#a28d87e3f42c52a12c95af0558aca66f2"> 125</a></span>&#160; <span class="keyword">static</span> std::tuple&lt;filename_t, filename_t&gt; <a class="code" href="classspdlog_1_1details_1_1file__helper.html#a28d87e3f42c52a12c95af0558aca66f2">split_by_extension</a>(<span class="keyword">const</span> <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">spdlog::filename_t</a> &amp;fname)</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; {</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; <span class="keyword">auto</span> ext_index = fname.rfind(<span class="charliteral">&#39;.&#39;</span>);</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>&#160;</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="comment">// no valid extension found - return whole path and empty string as</span></div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; <span class="comment">// extension</span></div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; <span class="keywordflow">if</span> (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1)</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; {</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; <span class="keywordflow">return</span> std::make_tuple(fname, <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">spdlog::filename_t</a>());</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160; }</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; <span class="comment">// treat casese like &quot;/etc/rc.d/somelogfile or &quot;/abc/.hiddenfile&quot;</span></div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; <span class="keyword">auto</span> folder_index = fname.rfind(<a class="code" href="namespacespdlog_1_1details_1_1os.html#afd9823831f24054f4fd6d734b90b7bc4">details::os::folder_sep</a>);</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; <span class="keywordflow">if</span> (folder_index != filename_t::npos &amp;&amp; folder_index &gt;= ext_index - 1)</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; {</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <span class="keywordflow">return</span> std::make_tuple(fname, <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">spdlog::filename_t</a>());</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; }</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160;</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; <span class="comment">// finally - return a valid base and extension tuple</span></div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; <span class="keywordflow">return</span> std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index));</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; }</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; std::FILE *fd_{<span class="keyword">nullptr</span>};</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; <a class="code" href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">filename_t</a> _filename;</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160;};</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160;} <span class="comment">// namespace details</span></div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160;} <span class="comment">// namespace spdlog</span></div><div class="ttc" id="classspdlog_1_1spdlog__ex_html"><div class="ttname"><a href="classspdlog_1_1spdlog__ex.html">spdlog::spdlog_ex</a></div><div class="ttdef"><b>Definition:</b> <a href="common_8h_source.html#l00175">common.h:175</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a22be952a421d866566eed3a5ce201144"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a22be952a421d866566eed3a5ce201144">spdlog::details::file_helper::open_tries</a></div><div class="ttdeci">const int open_tries</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00029">file_helper.h:29</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_aad84ef5f999c2721a0a8ad36ce641e8c"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#aad84ef5f999c2721a0a8ad36ce641e8c">spdlog::details::file_helper::~file_helper</a></div><div class="ttdeci">~file_helper()</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00037">file_helper.h:37</a></div></div>
<div class="ttc" id="namespacespdlog_1_1details_1_1os_html_a56a474fcf965264674346ffdefac0759"><div class="ttname"><a href="namespacespdlog_1_1details_1_1os.html#a56a474fcf965264674346ffdefac0759">spdlog::details::os::sleep_for_millis</a></div><div class="ttdeci">void sleep_for_millis(int milliseconds) noexcept</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00351">os.h:351</a></div></div>
<div class="ttc" id="classfmt_1_1v5_1_1basic__memory__buffer_html"><div class="ttname"><a href="classfmt_1_1v5_1_1basic__memory__buffer.html">fmt::v5::basic_memory_buffer</a></div><div class="ttdef"><b>Definition:</b> <a href="format_8h_source.html#l00464">format.h:464</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a8612066fd098080cc60e3aefed6a6085"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a8612066fd098080cc60e3aefed6a6085">spdlog::details::file_helper::open</a></div><div class="ttdeci">void open(const filename_t &amp;fname, bool truncate=false)</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00042">file_helper.h:42</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html">spdlog::details::file_helper</a></div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00025">file_helper.h:25</a></div></div>
<div class="ttc" id="namespacespdlog_1_1details_1_1os_html_a6d2fb5a293e8515f651288992d5443cc"><div class="ttname"><a href="namespacespdlog_1_1details_1_1os.html#a6d2fb5a293e8515f651288992d5443cc">spdlog::details::os::filesize</a></div><div class="ttdeci">size_t filesize(FILE *f)</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00204">os.h:204</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a21c688da7f241c53871b462c3a5c2c94"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a21c688da7f241c53871b462c3a5c2c94">spdlog::details::file_helper::reopen</a></div><div class="ttdeci">void reopen(bool truncate)</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00060">file_helper.h:60</a></div></div>
<div class="ttc" id="classfmt_1_1v5_1_1internal_1_1basic__buffer_html_a384f1304da6ce18c4713368327354479"><div class="ttname"><a href="classfmt_1_1v5_1_1internal_1_1basic__buffer.html#a384f1304da6ce18c4713368327354479">fmt::v5::internal::basic_buffer::data</a></div><div class="ttdeci">T * data()</div><div class="ttdef"><b>Definition:</b> <a href="core_8h_source.html#l00256">core.h:256</a></div></div>
<div class="ttc" id="namespacespdlog_html"><div class="ttname"><a href="namespacespdlog.html">spdlog</a></div><div class="ttdef"><b>Definition:</b> <a href="async_8h_source.html#l00027">async.h:27</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a28d87e3f42c52a12c95af0558aca66f2"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a28d87e3f42c52a12c95af0558aca66f2">spdlog::details::file_helper::split_by_extension</a></div><div class="ttdeci">static std::tuple&lt; filename_t, filename_t &gt; split_by_extension(const spdlog::filename_t &amp;fname)</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00125">file_helper.h:125</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a51eb58a2d46f1896f3ab7b9d323d97ae"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a51eb58a2d46f1896f3ab7b9d323d97ae">spdlog::details::file_helper::write</a></div><div class="ttdeci">void write(const fmt::memory_buffer &amp;buf)</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00083">file_helper.h:83</a></div></div>
<div class="ttc" id="namespacespdlog_1_1details_1_1os_html_af2d11a0b892e2f0cb3c6beba4c659a47"><div class="ttname"><a href="namespacespdlog_1_1details_1_1os.html#af2d11a0b892e2f0cb3c6beba4c659a47">spdlog::details::os::fopen_s</a></div><div class="ttdeci">bool fopen_s(FILE **fp, const filename_t &amp;filename, const filename_t &amp;mode)</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00148">os.h:148</a></div></div>
<div class="ttc" id="namespacefmt_1_1v5_1_1internal_html_ac62a332ee64650f2ebe0e8095fa8e7c0"><div class="ttname"><a href="namespacefmt_1_1v5_1_1internal.html#ac62a332ee64650f2ebe0e8095fa8e7c0">fmt::v5::internal::data</a></div><div class="ttdeci">basic_data data</div><div class="ttdef"><b>Definition:</b> <a href="format_8h_source.html#l00764">format.h:764</a></div></div>
<div class="ttc" id="namespacespdlog_html_acf7ce125b3622e44f8f1702d699e0b06"><div class="ttname"><a href="namespacespdlog.html#acf7ce125b3622e44f8f1702d699e0b06">spdlog::filename_t</a></div><div class="ttdeci">std::string filename_t</div><div class="ttdef"><b>Definition:</b> <a href="common_8h_source.html#l00205">common.h:205</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a76610058a1769b25bd6ed52a1443b552"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a76610058a1769b25bd6ed52a1443b552">spdlog::details::file_helper::filename</a></div><div class="ttdeci">const filename_t &amp; filename() const</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00102">file_helper.h:102</a></div></div>
<div class="ttc" id="os_8h_html"><div class="ttname"><a href="os_8h.html">os.h</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a7c7314360e404efa02326feb7aa98442"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a7c7314360e404efa02326feb7aa98442">spdlog::details::file_helper::operator=</a></div><div class="ttdeci">file_helper &amp; operator=(const file_helper &amp;)=delete</div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_aea72ea8d655bb11f19dbe48477e6c8b3"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#aea72ea8d655bb11f19dbe48477e6c8b3">spdlog::details::file_helper::open_interval</a></div><div class="ttdeci">const int open_interval</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00030">file_helper.h:30</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_ae945d9701134218c2d0558958e9d1cf2"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#ae945d9701134218c2d0558958e9d1cf2">spdlog::details::file_helper::size</a></div><div class="ttdeci">size_t size() const</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00093">file_helper.h:93</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a1a75f29ec0c13d9fbc269bcd8378b18b"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a1a75f29ec0c13d9fbc269bcd8378b18b">spdlog::details::file_helper::flush</a></div><div class="ttdeci">void flush()</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00069">file_helper.h:69</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a6a6d7a75014ae880857b4fe4fd01dc7a"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a6a6d7a75014ae880857b4fe4fd01dc7a">spdlog::details::file_helper::close</a></div><div class="ttdeci">void close()</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00074">file_helper.h:74</a></div></div>
<div class="ttc" id="classfmt_1_1v5_1_1internal_1_1basic__buffer_html_ac4761deba75a7238ae29243b159b9943"><div class="ttname"><a href="classfmt_1_1v5_1_1internal_1_1basic__buffer.html#ac4761deba75a7238ae29243b159b9943">fmt::v5::internal::basic_buffer::size</a></div><div class="ttdeci">std::size_t size() const</div><div class="ttdef"><b>Definition:</b> <a href="core_8h_source.html#l00250">core.h:250</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_a8c5f69588e8a54f436c3565317c233bd"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#a8c5f69588e8a54f436c3565317c233bd">spdlog::details::file_helper::file_exists</a></div><div class="ttdeci">static bool file_exists(const filename_t &amp;fname)</div><div class="ttdef"><b>Definition:</b> <a href="file__helper_8h_source.html#l00107">file_helper.h:107</a></div></div>
<div class="ttc" id="os_8h_html_a63d60ea1c1a925d3db13864d37bd2da2"><div class="ttname"><a href="os_8h.html#a63d60ea1c1a925d3db13864d37bd2da2">SPDLOG_FILENAME_T</a></div><div class="ttdeci">#define SPDLOG_FILENAME_T(s)</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00369">os.h:369</a></div></div>
<div class="ttc" id="namespacespdlog_1_1details_1_1os_html_afd466bafef75b9792e0ca62e7fdd8dc1"><div class="ttname"><a href="namespacespdlog_1_1details_1_1os.html#afd466bafef75b9792e0ca62e7fdd8dc1">spdlog::details::os::file_exists</a></div><div class="ttdeci">bool file_exists(const filename_t &amp;filename) noexcept</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00188">os.h:188</a></div></div>
<div class="ttc" id="log__msg_8h_html"><div class="ttname"><a href="log__msg_8h.html">log_msg.h</a></div></div>
<div class="ttc" id="namespacespdlog_1_1details_1_1os_html_afd9823831f24054f4fd6d734b90b7bc4"><div class="ttname"><a href="namespacespdlog_1_1details_1_1os.html#afd9823831f24054f4fd6d734b90b7bc4">spdlog::details::os::folder_sep</a></div><div class="ttdeci">static constexpr const char folder_sep</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00126">os.h:126</a></div></div>
<div class="ttc" id="namespacespdlog_1_1details_1_1os_html_ac7c0d6af1f3f652f23e57f057217b9a7"><div class="ttname"><a href="namespacespdlog_1_1details_1_1os.html#ac7c0d6af1f3f652f23e57f057217b9a7">spdlog::details::os::filename_to_str</a></div><div class="ttdeci">std::string filename_to_str(const filename_t &amp;filename)</div><div class="ttdef"><b>Definition:</b> <a href="os_8h_source.html#l00370">os.h:370</a></div></div>
<div class="ttc" id="classspdlog_1_1details_1_1file__helper_html_aa11a5129c9d7492638a68d849d66d47d"><div class="ttname"><a href="classspdlog_1_1details_1_1file__helper.html#aa11a5129c9d7492638a68d849d66d47d">spdlog::details::file_helper::file_helper</a></div><div class="ttdeci">file_helper()=default</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_5f1136fe404e0a548faf586fae339a6a.html">sdk_core</a></li><li class="navelem"><a class="el" href="dir_fef6b6f1028f30fedf17225feaaa02fe.html">include</a></li><li class="navelem"><a class="el" href="dir_7bb3e31efd6b819bbb0704cee4a66d41.html">third_party</a></li><li class="navelem"><a class="el" href="dir_cf58c3a45797022668a1e269b5315a33.html">spdlog</a></li><li class="navelem"><a class="el" href="dir_248a80cf6760c7a1ab13394a1c16f7b2.html">spdlog</a></li><li class="navelem"><a class="el" href="dir_7d093cd833acfccb787639923feedd9d.html">details</a></li><li class="navelem"><a class="el" href="file__helper_8h.html">file_helper.h</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
</ul>
</div>
</body>
</html>