source: NonGTP/Boost/boost/archive/tmpdir.hpp @ 857

Revision 857, 1.2 KB checked in by igarcia, 19 years ago (diff)
Line 
1#ifndef BOOST_ARCHIVE_TMPDIR_HPP
2#define BOOST_ARCHIVE_TMPDIR_HPP
3
4// MS compatible compilers support #pragma once
5#if defined(_MSC_VER) && (_MSC_VER >= 1020)
6# pragma once
7#endif
8
9/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10// tmpdir.hpp:
11
12// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13// Use, modification and distribution is subject to the Boost Software
14// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15// http://www.boost.org/LICENSE_1_0.txt)
16
17//  See http://www.boost.org for updates, documentation, and revision history.
18
19#include <cstdlib> // getenv
20#include <cassert>
21
22#include <boost/config.hpp>
23#ifdef BOOST_NO_STDC_NAMESPACE
24namespace std {
25    using ::getenv;
26}
27#endif
28
29namespace boost {
30namespace archive {
31
32char * tmpdir(){
33    char *dirname;
34    dirname = std::getenv("TMP");
35    if(NULL == dirname)
36        dirname = std::getenv("TMPDIR");
37    if(NULL == dirname)
38        dirname = std::getenv("TEMP");
39    if(NULL == dirname){
40        //assert(false); // no temp directory found
41        dirname = ".";
42    }
43    return dirname;
44}
45
46} // archive
47} // boost
48
49#endif // BOOST_ARCHIVE_TMPDIR_HPP
Note: See TracBrowser for help on using the repository browser.