Ticket #4724: temp_dir_path.patch
File temp_dir_path.patch, 6.2 KB (added by , 12 years ago) |
---|
-
boost/filesystem/v3/operations.hpp
188 188 BOOST_FILESYSTEM_DECL 189 189 path system_complete(const path& p, system::error_code* ec=0); 190 190 BOOST_FILESYSTEM_DECL 191 path temp_dir_path(system::error_code* ec=0); 192 BOOST_FILESYSTEM_DECL 191 193 path unique_path(const path& p, system::error_code* ec=0); 192 194 } // namespace detail 193 195 … … 443 445 path system_complete(const path& p, system::error_code& ec) 444 446 {return detail::system_complete(p, &ec);} 445 447 inline 448 path temp_dir_path() {return detail::temp_dir_path();} 449 450 inline 451 path temp_dir_path(system::error_code& ec) 452 {return detail::temp_dir_path(&ec);} 453 inline 446 454 path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%") 447 455 { return detail::unique_path(p); } 448 456 inline … … 982 990 using filesystem3::symlink_file; 983 991 using filesystem3::symlink_status; 984 992 using filesystem3::system_complete; 993 using filesystem3::temp_dir_path; 985 994 using filesystem3::type_unknown; 986 995 using filesystem3::unique_path; 987 996 # ifndef BOOST_FILESYSTEM_NO_DEPRECATED -
libs/filesystem/v3/test/operations_test.cpp
1269 1269 BOOST_TEST(!fs::equivalent(ng, file_ph)); 1270 1270 } 1271 1271 1272 // temp_dir_path_tests ---------------------------------------------------------// 1273 1274 void temp_dir_path_tests() 1275 { 1276 std::cout << "temp_dir_path_tests..." << std::endl; 1277 1278 BOOST_TEST(!fs::temp_dir_path().empty()); 1279 BOOST_TEST(exists(fs::temp_dir_path())); 1280 } 1281 1272 1282 // _tests --------------------------------------------------------------------------// 1273 1283 1274 1284 void _tests() … … 1393 1403 if (create_symlink_ok) // only if symlinks supported 1394 1404 remove_symlink_tests(); 1395 1405 write_time_tests(dir); 1396 1406 1407 temp_dir_path_tests(); 1408 1397 1409 std::cout << "testing complete" << std::endl; 1398 1410 1399 1411 // post-test cleanup -
libs/filesystem/v3/doc/reference.html
114 114   <a href="#status_known">status_known</a><br> 115 115   <a href="#symlink_status">symlink_status</a><br> 116 116   <a href="#system_complete">system_complete</a><br> 117   <a href="#temp_dir_path">temp_dir_path</a><br> 117 118 <a href="#unique_path">unique_path</a></td> 118 119 <td width="34%" valign="top"> 119 120 <a href="#File-streams">File streams</a><br> … … 437 438 path <a href="#system_complete">system_complete</a>(const path& p); 438 439 path <a href="#system_complete">system_complete</a>(const path& p, system::error_code& ec); 439 440 441 path <a href="#temp_dir_path">temp_dir_path</a>(); 442 path <a href="#temp_dir_path">temp_dir_path</a>(system::error_code& ec); 443 440 444 path <a href="#unique_path">unique_path</a>(const path& model="%%%%-%%%%-%%%%-%%%%"); 441 445 path <a href="#unique_path">unique_path</a>(const path& model, system::error_code& ec); 442 446 … … 2442 2446 <p>See <a href="#complete_note"> 2443 2447 <i>complete()</i> note</a> for usage suggestions. <i>-- end note</i>]</p> 2444 2448 </blockquote> 2449 <pre>path <a name="temp_dir_path">temp_dir_path</a>(); 2450 path temp_dir_path(system::error_code& ec);</pre> 2451 <blockquote> 2452 <p><i>Returns:</i> The temporary directory path as returned by the <i>POSIX</i> <code>getenv("TMPDIR")</code> environment variable, 2453 or the <i>Windows</i> <code>GetTempPath</code> API function. <code>is_directory()</code> is true for the returned path.</p> 2454 <p><i>Throws:</i> As specified in 2455 <a href="#Error-reporting"> 2456 Error reporting</a>.</p> 2457 <p>[<i>Note: </i>The <code>temp_dir_path()</code> name was chosen to emphasize that the return is a 2458 path, not just a single directory name. <i>-- end note</i>]</p> 2459 </blockquote> 2445 2460 <pre>path <a name="unique_path">unique_path</a>(const path& model="%%%%-%%%%-%%%%-%%%%"); 2446 2461 path unique_path(const path& model, system::error_code& ec);</pre> 2447 2462 <blockquote> -
libs/filesystem/v3/src/operations.cpp
49 49 #include <boost/scoped_array.hpp> 50 50 #include <boost/detail/workaround.hpp> 51 51 #include <cstdlib> // for malloc, free 52 #include <vector> 52 53 53 54 #ifdef BOOST_FILEYSTEM_INCLUDE_IOSTREAM 54 55 # include <iostream> … … 1445 1446 } 1446 1447 1447 1448 BOOST_FILESYSTEM_DECL 1449 path temp_dir_path(system::error_code* ec) 1450 { 1451 # ifdef BOOST_POSIX_API 1452 const char* val = std::getenv("TMPDIR"); 1453 1454 if (error(val==0, 1455 ec, "boost::filesystem::temp_dir_path")) 1456 return path(); 1457 1458 path p(val); 1459 1460 if (error((ec && !is_directory(p, *ec)) || 1461 (!ec && !is_directory(p)), 1462 ec, "boost::filesystem::temp_dir_path")) 1463 return path(); 1464 1465 return p; 1466 1467 # else // Windows 1468 1469 std::vector<path::value_type> buf(GetTempPathW(0, NULL)); 1470 1471 if (error(buf.empty() || GetTempPathW(buf.size(), &buf[0])==0, 1472 ec, "boost::filesystem::temp_dir_path")) 1473 return path(); 1474 1475 buf.pop_back(); 1476 1477 path p(buf.begin(), buf.end()); 1478 1479 if (error((ec && !is_directory(p, *ec)) || 1480 (!ec && !is_directory(p)), 1481 ec, "boost::filesystem::temp_dir_path")) 1482 return path(); 1483 1484 return p; 1485 # endif 1486 } 1487 1488 BOOST_FILESYSTEM_DECL 1448 1489 path system_complete(const path& p, system::error_code* ec) 1449 1490 { 1450 1491 # ifdef BOOST_POSIX_API