Files
hustoj/web/cppreference-zh/chmhelp/cpp-filesystem-filesystem_error-filesystem_error.html
2025-08-01 12:57:54 +08:00

103 lines
8.2 KiB
HTML

<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>std::filesystem::filesystem_error::filesystem_error</title>
<link rel="stylesheet" href="ext.css" />
<link rel="stylesheet" href="site_modules.css" />
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_filesystem_filesystem_error_filesystem_error skin-cppreference2 action-view cpp-navbar">
<div id="cpp-content-base">
<div id="content"><a id="top"></a>
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::filesystem::filesystem_error::</span>filesystem_error</h1>
<div id="bodyContent">
<div id="contentSub"><span class="subpages">&lt; <a href="cpp.html">cpp</a>&lrm; | <a href="cpp-filesystem.html">filesystem</a>&lrm; | <a href="cpp-filesystem-filesystem_error.html">filesystem error</a></span></div>
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
<table class="t-dcl-begin">
<tbody>
<tr class="t-dcl t-since-cxx17">
<td>
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <span class="kw4">const</span> <a href="cpp-string-basic_string.html"><span class="kw1230">std::<span class="me2">string</span></span></a><span class="sy3">&amp;</span> what_arg,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="cpp-error-error_code.html"><span class="kw877">std::<span class="me2">error_code</span></span></a> ec <span class="br0">)</span><span class="sy4">;</span></span></div>
</td>
<td>(1)</td>
<td><span class="t-mark-rev t-since-cxx17">(C++17 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td>
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <span class="kw4">const</span> <a href="cpp-string-basic_string.html"><span class="kw1230">std::<span class="me2">string</span></span></a><span class="sy3">&amp;</span> what_arg,<br /></span>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">const</span> <a href="cpp-filesystem-path.html"><span class="kw2199">std::<span class="me2">filesystem</span><span class="sy4">::</span><span class="me2">path</span></span></a><span class="sy3">&amp;</span> p1,<br /></p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="cpp-error-error_code.html"><span class="kw877">std::<span class="me2">error_code</span></span></a> ec <span class="br0">)</span><span class="sy4">;</span></div>
</td>
<td>(2)</td>
<td><span class="t-mark-rev t-since-cxx17">(C++17 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td>
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <span class="kw4">const</span> <a href="cpp-string-basic_string.html"><span class="kw1230">std::<span class="me2">string</span></span></a><span class="sy3">&amp;</span> what_arg,<br /></span>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">const</span> <a href="cpp-filesystem-path.html"><span class="kw2199">std::<span class="me2">filesystem</span><span class="sy4">::</span><span class="me2">path</span></span></a><span class="sy3">&amp;</span> p1,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">const</span> <a href="cpp-filesystem-path.html"><span class="kw2199">std::<span class="me2">filesystem</span><span class="sy4">::</span><span class="me2">path</span></span></a><span class="sy3">&amp;</span> p2,<br /></p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="cpp-error-error_code.html"><span class="kw877">std::<span class="me2">error_code</span></span></a> ec <span class="br0">)</span><span class="sy4">;</span></div>
</td>
<td>(3)</td>
<td><span class="t-mark-rev t-since-cxx17">(C++17 &#36215;)</span></td>
</tr>
<tr class="t-dcl t-since-cxx17">
<td>
<div><span class="mw-geshi cpp source-cpp">filesystem_error<span class="br0">(</span> <span class="kw4">const</span> filesystem_error<span class="sy3">&amp;</span> other <span class="br0">)</span> <span class="kw1">noexcept</span><span class="sy4">;</span></span></div>
</td>
<td>(4)</td>
<td><span class="t-mark-rev t-since-cxx17">(C++17 &#36215;)</span></td>
</tr>
<tr class="t-dcl-sep">
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>&#26500;&#36896;&#26032;&#30340;&#25991;&#20214;&#31995;&#32479;&#38169;&#35823;&#23545;&#35937;&#12290;</p>
<div class="t-li1"><span class="t-li">1-3)</span> &#35774;&#32622;&#38169;&#35823;&#30721;&#20026; <code>ec</code> &#65292;&#21487;&#36873;&#22320;&#23558;&#23548;&#33268;&#35813;&#38169;&#35823;&#30340;&#25805;&#20316;&#20013;&#35774;&#35745;&#30340;&#36335;&#24452;&#35774;&#20026; <code>p1</code> &#21644; <code>p2</code> &#12290;&#26500;&#36896;&#21518; <code>what()</code> &#36820;&#22238;&#21547;&#26377; <code>what_arg</code> &#30340; string &#65288;&#20551;&#23450;&#23427;&#19981;&#21547;&#20869;&#23884;&#30340;&#31354;&#23383;&#31526; &#65289;&#12290;&#33509;&#26410;&#25552;&#20379;&#19968;&#20010;&#25110;&#20004;&#20010; <code>path</code> &#21442;&#25968;&#65292;&#21017;&#29992; <code>path</code> &#20195;&#26367;&#12290;</div>
<div class="t-li1"><span class="t-li">4)</span> &#22797;&#21046;&#26500;&#36896;&#20989;&#25968;&#12290;&#20197; <code>other</code> &#30340;&#20869;&#23481;&#21021;&#22987;&#21270;&#20869;&#23481;&#12290;&#33509; <code>*this</code> &#19982; <code>other</code> &#22343;&#25317;&#26377;&#21160;&#24577;&#31867;&#22411; <code>std::filesystem_error::filesystem_error</code> &#21017; <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="cpp-string-byte-strcmp.html"><span class="kw1146">std::<span class="me2">strcmp</span></span></a><span class="br0">(</span>what<span class="br0">(</span><span class="br0">)</span>, other.<span class="me1">what</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span> <span class="sy1">==</span> <span class="nu0">0</span></span></span> &#12290;</div>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>what_arg</td>
<td>-</td>
<td>&#35299;&#37322;&#23383;&#31526;&#20018;</td>
</tr>
<tr class="t-par">
<td>ec</td>
<td>-</td>
<td>&#20381;&#36182;&#29305;&#23450;&#25805;&#20316;&#31995;&#32479;&#30340;&#38169;&#35823;&#30340;&#38169;&#35823;&#30721;</td>
</tr>
<tr class="t-par">
<td>p1, p2</td>
<td>-</td>
<td>&#24341;&#21457;&#31995;&#32479;&#38169;&#35823;&#30340;&#25805;&#20316;&#20013;&#28041;&#21450;&#30340;&#36335;&#24452;</td>
</tr>
<tr class="t-par">
<td>other</td>
<td>-</td>
<td>&#35201;&#22797;&#21046;&#30340;&#21478;&#19968; <code>filesystem_error</code> &#23545;&#35937;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E6.B3.A8.E8.A7.A3">&#27880;&#35299;</span></h3>
<p>&#22240;&#20026;&#19981;&#23481;&#35768;&#22797;&#21046; <code>std::filesystem::filesystem_error</code> &#25243;&#24322;&#24120;&#65292;&#35299;&#37322;&#23383;&#31526;&#20018;&#24120;&#34987;&#22312;&#20869;&#37096;&#23384;&#20648;&#20110;&#20998;&#31163;&#20998;&#37197;&#30340;&#24341;&#29992;&#35745;&#25968;&#23384;&#20648;&#12290;&#36825;&#20063;&#26159;&#26080;&#26500;&#36896;&#20989;&#25968;&#25509;&#25910; <code>std::string&amp;&amp;</code> &#30340;&#21407;&#22240;&#65306;&#23427;&#24635;&#26159;&#35201;&#22797;&#21046;&#20869;&#23481;&#12290;</p>
<p>&#20856;&#22411;&#23454;&#29616;&#20134;&#23558; <span class="t-lc"><a href="cpp-filesystem-filesystem_error-path.html">path1()</a></span> &#19982; <span class="t-lc"><a href="cpp-filesystem-filesystem_error-path.html">path2()</a></span> &#25152;&#24341;&#29992;&#30340; <code>path</code> &#23545;&#35937;&#23384;&#20648;&#20110;&#24341;&#29992;&#35745;&#25968;&#23384;&#20648;&#12290;</p>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">&#31034;&#20363;</span></h3>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style="">
<tr>
<td class="mbox-empty-cell"></td>
<td class="mbox-text" style="">&#26412;&#33410;&#26410;&#23436;&#25104;<br />
&#21407;&#22240;&#65306;&#26242;&#26080;&#31034;&#20363;</td>
</tr>
</table>
</div>
<div class="visualClear"></div>
</div>
</div>
</div>
</body>
</html>