tmpdir.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef BOOST_ARCHIVE_TMPDIR_HPP
  2. #define BOOST_ARCHIVE_TMPDIR_HPP
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER)
  5. # pragma once
  6. #endif
  7. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  8. // tmpdir.hpp:
  9. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  10. // Use, modification and distribution is subject to the Boost Software
  11. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. // See http://www.boost.org for updates, documentation, and revision history.
  14. #include <cstdlib> // getenv
  15. #include <cstddef> // NULL
  16. //#include <boost/assert.hpp>
  17. #include <boost/config.hpp>
  18. #ifdef BOOST_NO_STDC_NAMESPACE
  19. namespace std {
  20. using ::getenv;
  21. }
  22. #endif
  23. namespace boost {
  24. namespace archive {
  25. inline const char * tmpdir(){
  26. const char *dirname;
  27. dirname = std::getenv("TMP");
  28. if(NULL == dirname)
  29. dirname = std::getenv("TMPDIR");
  30. if(NULL == dirname)
  31. dirname = std::getenv("TEMP");
  32. if(NULL == dirname){
  33. //BOOST_ASSERT(false); // no temp directory found
  34. dirname = ".";
  35. }
  36. return dirname;
  37. }
  38. } // archive
  39. } // boost
  40. #endif // BOOST_ARCHIVE_TMPDIR_HPP