mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-29 19:42:08 +00:00
For POSIX temp_directory_path, if none of environmental variables are found, try "/tmp".
[SVN r66038]
This commit is contained in:
@@ -2453,8 +2453,8 @@ path temp_directory_path(system::error_code& ec);</pre>
|
||||
conventions of the operating system. The specifics of how this path is
|
||||
determined are implementation defined. An error shall be reported if<code> !exists(p)
|
||||
|| !is_directory(p)</code>, where <code>p</code> is the path to be returned.</p>
|
||||
<p><i>POSIX:</i> The path supplied by the first environment variable in the
|
||||
list TMPDIR, TMP, TEMP, TEMPDIR that names an existing directory.</p>
|
||||
<p><i>POSIX:</i> The path supplied by the first environment variable found in the
|
||||
list TMPDIR, TMP, TEMP, TEMPDIR. If none of these are found, <code>"/tmp"</code>.</p>
|
||||
<p><i>Windows:</i> The path reported by the <i>Windows</i> <code>GetTempPath</code> API function.</p>
|
||||
<p><i>Throws:</i> As specified in <a href="#Error-reporting">
|
||||
Error reporting</a>.</p>
|
||||
@@ -3089,7 +3089,7 @@ multiple string types. His idea became the basis for the version 3 path design.<
|
||||
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->16 October 2010<!--webbot bot="Timestamp" endspan i-checksum="32126" --></p>
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->17 October 2010<!--webbot bot="Timestamp" endspan i-checksum="32128" --></p>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
@@ -1525,12 +1525,12 @@ namespace detail
|
||||
(val = std::getenv("TEMP" )) ||
|
||||
(val = std::getenv("TEMPDIR"));
|
||||
|
||||
path p((val!=0)? val : "");
|
||||
path p((val!=0) ? val : "/tmp");
|
||||
|
||||
if(!val||(ec&&!is_directory(p, *ec))||(!ec&&!is_directory(p)))
|
||||
if (p.empty() || (ec&&!is_directory(p, *ec))||(!ec&&!is_directory(p)))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
error(true, ec, "boost::filesystem::temp_directory_path");
|
||||
error(true, p, ec, "boost::filesystem::temp_directory_path");
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1540,7 +1540,7 @@ namespace detail
|
||||
|
||||
std::vector<path::value_type> buf(GetTempPathW(0, NULL));
|
||||
|
||||
if(buf.empty() || GetTempPathW(buf.size(), &buf[0])==0)
|
||||
if (buf.empty() || GetTempPathW(buf.size(), &buf[0])==0)
|
||||
{
|
||||
if(!buf.empty()) ::SetLastError(ENOTDIR);
|
||||
error(true, ec, "boost::filesystem::temp_directory_path");
|
||||
@@ -1551,10 +1551,10 @@ namespace detail
|
||||
|
||||
path p(buf.begin(), buf.end());
|
||||
|
||||
if((ec&&!is_directory(p, *ec))||(!ec&&!is_directory(p)))
|
||||
if ((ec&&!is_directory(p, *ec))||(!ec&&!is_directory(p)))
|
||||
{
|
||||
::SetLastError(ENOTDIR);
|
||||
error(true, ec, "boost::filesystem::temp_directory_path");
|
||||
error(true, p, ec, "boost::filesystem::temp_directory_path");
|
||||
return path();
|
||||
}
|
||||
|
||||
|
||||
@@ -1525,43 +1525,23 @@ namespace
|
||||
{}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
guarded_tmp_vars vars(0, 0, 0, 0);
|
||||
fs::path ph = fs::temp_directory_path();
|
||||
|
||||
BOOST_TEST(false); // should throw
|
||||
}
|
||||
catch(const boost::filesystem::filesystem_error& e)
|
||||
{
|
||||
BOOST_TEST(e.code() == boost::system::errc::not_a_directory);
|
||||
}
|
||||
|
||||
{
|
||||
guarded_tmp_vars vars(0, 0, 0, 0);
|
||||
error_code ec;
|
||||
fs::path ph = fs::temp_directory_path(ec);
|
||||
BOOST_TEST(ec);
|
||||
BOOST_TEST(ec == boost::system::errc::not_a_directory);
|
||||
}
|
||||
|
||||
{
|
||||
guarded_tmp_vars vars(test_temp_dir.BOOST_FILESYSTEM_C_STR, 0, 0, 0);
|
||||
guarded_tmp_vars vars(test_temp_dir.c_str(), 0, 0, 0);
|
||||
fs::path ph = fs::temp_directory_path();
|
||||
BOOST_TEST(equivalent(test_temp_dir, ph));
|
||||
}
|
||||
{
|
||||
guarded_tmp_vars vars(0, test_temp_dir.BOOST_FILESYSTEM_C_STR, 0, 0);
|
||||
guarded_tmp_vars vars(0, test_temp_dir.c_str(), 0, 0);
|
||||
fs::path ph = fs::temp_directory_path();
|
||||
BOOST_TEST(equivalent(test_temp_dir, ph));
|
||||
}
|
||||
{
|
||||
guarded_tmp_vars vars(0, 0, test_temp_dir.BOOST_FILESYSTEM_C_STR, 0);
|
||||
guarded_tmp_vars vars(0, 0, test_temp_dir.c_str(), 0);
|
||||
fs::path ph = fs::temp_directory_path();
|
||||
BOOST_TEST(equivalent(test_temp_dir, ph));
|
||||
}
|
||||
{
|
||||
guarded_tmp_vars vars(0, 0, 0, test_temp_dir.BOOST_FILESYSTEM_C_STR);
|
||||
guarded_tmp_vars vars(0, 0, 0, test_temp_dir.c_str());
|
||||
fs::path ph = fs::temp_directory_path();
|
||||
BOOST_TEST(equivalent(test_temp_dir, ph));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user