<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2678: std::filesystem enum classes overspecified</title>
<meta property="og:title" content="Issue 2678: std::filesystem enum classes overspecified">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2678.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++17">C++17</a> status.</em></p>
<h3 id="2678"><a href="lwg-defects.html#2678">2678</a>. <code>std::filesystem</code> enum classes overspecified</h3>
<p><b>Section:</b> 31.12.8.2 <a href="https://wg21.link/fs.enum.file.type">[fs.enum.file.type]</a>, 31.12.8.3 <a href="https://wg21.link/fs.enum.copy.opts">[fs.enum.copy.opts]</a>, 31.12.8.6 <a href="https://wg21.link/fs.enum.dir.opts">[fs.enum.dir.opts]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Richard Smith <b>Opened:</b> 2016-03-19 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.enum.file.type">issues</a> in [fs.enum.file.type].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The enum class <code>std::filesystem::file_type</code> specifies a collection of enumerators for describing the type of
a file, but also specifies (1) the numeric values of the enumerators, and (2) that an implementation cannot extend the
list with additional types known to it (and by extension, the standard cannot extend the list in future versions without
breakage).
</p>
<p>
These both seem like mistakes in the design. I would suggest we remove the
specification of numerical values, and maybe also
</p>
<ul>
  <li><p>we allow implementations to add new implementation-defined value</p></li>
  <li><p>we replace <code>std::filesystem::file_type::unknown</code> with a value that <em>only</em>
  means &quot;exists but type could not be determined&quot; and use
  implementation-specific values for other possibilities.</p></li>
</ul>
 <p>
 Similar overspecification exists for <code>std::filesystem::copy_options</code> and
 <code>std::filesystem::directory_options</code>, where again precise numerical values are specified.
 </p>

<p><i>[2016-08 Chicago]</i></p>

<p>Wed AM: Move to Tentatively Ready</p>


<p id="res-2678"><b>Proposed resolution:</b></p>
<ol>
<li>
<p>
Strike the "Value" column from:
</p>
<ul>
  <li><p> [fs.enum.file_type], Table 145 Enum class <code>file_type</code> </p></li>
  <li><p>31.12.8.3 <a href="https://wg21.link/fs.enum.copy.opts">[fs.enum.copy.opts]</a>, Table 146 Enum class <code>copy_options</code> </p></li>
  <li><p>31.12.8.6 <a href="https://wg21.link/fs.enum.dir.opts">[fs.enum.dir.opts]</a>, Table 148 Enum class <code>enum.directory_options</code>.</p></li>
</ul>
</li>

<li><p>Change  [fs.enum.file_type] Table 145 Enum class <code>file_type</code> as indicated:</p>

<blockquote>
 <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
    <tr>
      <td><b>Constant</b></td>
      <td><b>Meaning</b></td>
    </tr>
    <tr>
      <td><code>none</code></td>
      <td>The type of the file has not been determined or an error occurred
      while trying to determine the type.</td>
    </tr>
    <tr>
      <td><code>not_found</code></td>
      <td>Pseudo-type indicating the file was not found. [ <i>Note:</i>
      The file not being
      found is not considered an error while determining the type of a file.
      <i>—end note</i> ]</td>
    </tr>
    <tr>
      <td><code>regular</code></td>
      <td>Regular file</td>
    </tr>
    <tr>
      <td><code>directory</code></td>
      <td>Directory file</td>
    </tr>
    <tr>
      <td><code>symlink</code></td>
      <td>Symbolic link file</td>
    </tr>
    <tr>
      <td><code>block</code></td>
      <td>Block special file</td>
    </tr>
    <tr>
      <td><code>character</code></td>
      <td>Character special file</td>
    </tr>
    <tr>
      <td><code>fifo</code></td>
      <td>FIFO or pipe file</td>
    </tr>
    <tr>
      <td><code>socket</code></td>
      <td>Socket file</td>
    </tr>
    <tr>
      <td><ins>implementation-<br/>defined</ins></td>
      <td><ins>Implementations that support file systems having file types
      in addition to the above file_type types shall supply
      implementation-defined <code>file_type</code>
      constants to separately identify each of those additional
      file types</ins></td>
    </tr>
    <tr>
      <td><code>unknown</code></td>
      <td><del>The file does exist, but is of an operating system dependent type not
      covered by any of the other cases or the process does not have permission to query
      the file type</del> <ins>The file exists but the type could not be determined</ins></td>
    </tr>
  </table>
</blockquote>
</li>
</ol>






</body>
</html>
