<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2663: Enable efficient retrieval of file size from directory_entry</title>
<meta property="og:title" content="Issue 2663: Enable efficient retrieval of file size from directory_entry">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2663.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#Resolved">Resolved</a> status.</em></p>
<h3 id="2663"><a href="lwg-defects.html#2663">2663</a>. Enable efficient retrieval of file size from <code>directory_entry</code></h3>
<p><b>Section:</b> 31.12.13.15 <a href="https://wg21.link/fs.op.file.size">[fs.op.file.size]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Gor Nishanov <b>Opened:</b> 2014-05-22 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>2
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
  On Windows, the <code><del>FindFileData</del> <ins>WIN32_FIND_DATA</ins></code> structure, which is the underlying data type for <code>directory_entry</code>, contains the file size as one of the fields.

  Thus efficient enumeration of files and getting their sizes is possible without doing a separate query for the file size.

</p>
  <p><i>[17 Jun 2014 Rapperswil LWG will investigate issue at a subsequent meeting.]</i></p>

  <p><i>[23 Nov 2015 Editorally correct name of data structure mentioned in discussion.]</i></p>


<p><i>[Mar 2016 Jacksonville Beman to provide paper about this]</i></p>


<p><i>[<b>Apr 2016 Issue updated to address the C++ Working Paper. Previously addressed File System TS</b>]</i></p>


<p><strong>Previous resolution [SUPERSEDED]</strong></p>
<blockquote class="note">
  <p>
    <i>
      In  [fs.class.directory_entry] Class <code>directory_entry</code> add the
      following observer declarations:
    </i>
  </p>
  <p></p>
  <blockquote>
    <pre>
      uintmax_t file_size();
      uintmax_t file_size(error_code&amp; ec) noexcept;
    </pre>
  </blockquote>
  <p>
    <i>
      In <code>directory_entry</code> observers 31.12.10.4 <a href="https://wg21.link/fs.dir.entry.obs">[fs.dir.entry.obs]</a>
      add the following:
    </i>
  </p>
  <p></p>
  <blockquote>
    <pre>
      uintmax_t file_size();
      uintmax_t file_size(error_code&amp; ec) noexcept;
    </pre>
    <p></p>
    <blockquote>
      <p>
        <i>Returns:</i> if <code>*this</code> contains a cached file size, return
        it.
        Otherwise return <code>file_size(path())</code> or <code>file_size(path(), ec)</code>
        respectively.
      </p>
      <p>
        <i>Throws:</i> As specified in Error reporting (7).
      </p>
    </blockquote>
  </blockquote>
</blockquote>

<p><i>[2016-08, Beman comments]</i></p>

<p>
This will be resolved by <a href="https://wg21.link/p0317r1">P0317R1</a>, Directory Entry Caching for Filesystem.
<p>Fri AM: Moved to Tentatively Resolved</p>
</p>



<p id="res-2663"><b>Proposed resolution:</b></p>





</body>
</html>
