diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-27 19:05:23 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-05-04 20:28:50 +0300 |
commit | d20431e11290320f04d62e26b9a7cbcefaf5480c (patch) | |
tree | 76fd8820f079168aaced608b7c61e0923b260f5f /butl/path | |
parent | 6cd172c32ebe79692e19433f49716e58c57c8677 (diff) |
Add temp_directory(), temp_path()
Diffstat (limited to 'butl/path')
-rw-r--r-- | butl/path | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -159,6 +159,20 @@ namespace butl static void current (string_type const&); + // Return the temporary directory. Throw std::system_error to report the + // underlying OS errors. + // + static string_type + temp_directory (); + + // Return a temporary name. The name is constructed by starting with the + // prefix followed by the process id following by a unique counter value + // inside the process. Throw std::system_error to report the underlying OS + // errors. + // + static string_type + temp_name (string_type const& prefix); + // Make the path real (by calling realpath(3)). Throw invalid_basic_path // if the path is invalid (e.g., some components do not exist) and // std::system_error to report other underlying OS errors. @@ -302,6 +316,24 @@ namespace butl static void current (basic_path const&); + // Return the temporary directory. Throw std::system_error to report the + // underlying OS errors. + // + static dir_type + temp_directory () {return dir_type (traits::temp_directory ());} + + // Return a temporary path. The path is constructed by starting with the + // temporary directory and then appending a path component consisting of + // the prefix followed by the process id following by a unique counter + // value inside the process. Throw std::system_error to report the + // underlying OS errors. + // + static basic_path + temp_path (const string_type& prefix) + { + return temp_directory () / basic_path (traits::temp_name (prefix)); + } + public: bool empty () const |