Boost C++ Libraries: Ticket #2725: boost::filesystem::exists throws on Windows if the drive letter doesn't exist https://svn.boost.org/trac10/ticket/2725 <p> boost::filesystem::exists throws on Windows if the drive letter doesn't exist. </p> <p> This is rather unexpected. It's rather tedious to validate the drive letter beforehand or to have to catch the exception. </p> <p> I think it's reasonable to say that if the drive doesn't exist then the file doesn't exist. </p> <p> I noted that status_template checks a list of errors returned by get_file_attributes: </p> <blockquote> <p> if ((ec.value() == ERROR_FILE_NOT_FOUND) </p> <blockquote> <table class="wiki"> <tr><td> (ec.value() == ERROR_PATH_NOT_FOUND) </td></tr><tr><td> (ec.value() == ERROR_INVALID_NAME) <em> "tools/jam/src/:sys:stat.h", "</em>foo" </td></tr><tr><td> (ec.value() == ERROR_INVALID_PARAMETER) <em> ":sys:stat.h" </em></td></tr><tr><td> (ec.value() == ERROR_BAD_PATHNAME) <em> "</em>nosuch" on Win64 </td></tr><tr><td> (ec.value() == ERROR_BAD_NETPATH </td></tr></table> </blockquote> </blockquote> <p> I would propose adding ERROR_INVALID_DRIVE to this list. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2725 Trac 1.4.3 anonymous Wed, 04 Feb 2009 15:34:56 GMT <link>https://svn.boost.org/trac10/ticket/2725#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2725#comment:1</guid> <description> <p> Hello, </p> <p> I have a correction to this issue. My invalid drive is actually a removable disk (USB) so actually the drive letter *does* exist but nothing is inserted. I suppose its therefore justified that an exception is thrown. </p> <p> Yours, </p> <p> David. </p> </description> <category>Ticket</category> </item> <item> <author>megibson@…</author> <pubDate>Fri, 20 Mar 2009 16:16:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2725#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2725#comment:2</guid> <description> <p> If the drive does not exist, then the file does not exist. Special cases are nice, but this function does not do the right thing when the drive does not exist. I don't see how the previous comment is relevant. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Mon, 23 Mar 2009 11:30:59 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2725#comment:3 https://svn.boost.org/trac10/ticket/2725#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51931" title="Fix #2725">[51931]</a>) Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2725" title="#2725: Bugs: boost::filesystem::exists throws on Windows if the drive letter ... (closed: worksforme)">#2725</a> </p> Ticket claudio@… Thu, 22 Jul 2010 13:50:34 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/2725#comment:4 https://svn.boost.org/trac10/ticket/2725#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> boost::filesystem::exists also throws if the drive is an empty CD/DVD drive. </p> <p> I think it's reasonable to say that if the CD/DVD drive is empty then the file doesn't exist. </p> <p> For an empty CD/DVD drive ec.value() == ERROR_NOT_READY </p> Ticket Beman Dawes Tue, 31 May 2011 15:18:45 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2725#comment:5 https://svn.boost.org/trac10/ticket/2725#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> I can't reproduce the problem with v3 on the current trunk. </p> <p> I've added a program, .../libs/filesystem/v3/example/file_status.cpp to the trunk. It can be built with bjam in that directory. </p> <p> Please give it a try and send me the output if you are still having problems. </p> <p> --Beman </p> Ticket