<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3079: LWG 2935 forgot to fix the existing_p overloads of create_directory</title>
<meta property="og:title" content="Issue 3079: LWG 2935 forgot to fix the existing_p overloads of create_directory">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3079.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++20">C++20</a> status.</em></p>
<h3 id="3079"><a href="lwg-defects.html#3079">3079</a>. LWG 2935 forgot to fix the <code>existing_p</code> overloads of <code>create_directory</code></h3>
<p><b>Section:</b> 31.12.13.8 <a href="https://wg21.link/fs.op.create.directory">[fs.op.create.directory]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Billy O'Neal III <b>Opened:</b> 2018-03-07 <b>Last modified:</b> 2021-06-06</p>
<p><b>Priority: </b>0
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
LWG <a href="lwg-defects.html#2935" title="What should create_directories do when p already exists but is not a directory? (Status: C++20)">2935</a><sup><a href="https://cplusplus.github.io/LWG/issue2935" title="Latest snapshot">(i)</a></sup> clarified that <code>create_directory</code> is not supposed to report an error if
<code>exists(p)</code>, even if <code>p</code> is not a directory. However, the P/R there missed the
<code>existing_p</code> overloads.
</p>

<p><i>[
2018-03-27 Moved to Tentatively Ready after 6 positive votes on c++std-lib.
]</i></p>


<p><i>[2018-06 Rapperswil: Adopted]</i></p>



<p id="res-3079"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/n4727">N4727</a>.
</p>

<ol>
<li>
<p>Edit  [fs.op.create_directory] as indicated:</p>
<blockquote>
<pre>
bool create_directory(const path&amp; p, const path&amp; existing_p);
bool create_directory(const path&amp; p, const path&amp; existing_p, error_code&amp; ec) noexcept;
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> <del>Establishes the postcondition by attempting to create</del><ins>Creates</ins>
the directory <code>p</code> resolves to, with attributes copied from directory <code>existing_p</code>.
The set of attributes copied is operating system dependent. Creation failure because <code>p</code>
<del>resolves to an existing directory shall not be treated as</del><ins>already exists is not</ins>
an error. [<i>Note:</i> For POSIX-based operating systems, the attributes
are those copied by native API <code>stat(existing_p.c_str(), &amp;attributes_stat)</code> followed by
<code>mkdir(p.c_str(), attributes_stat.st_mode)</code>. For Windows-based operating systems, the attributes
are those copied by native API <code>CreateDirectoryExW(existing_p.c_str(), p.c_str(), 0)</code>. &mdash;
<i>end note</i>]
<p/>
<del>-5- <i>Postconditions:</i> <code>is_directory(p)</code>.</del>
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
