os/ossrv/ossrv_pub/boost_apis/boost/archive/tmpdir.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
#ifndef BOOST_ARCHIVE_TMPDIR_HPP
sl@0
     2
#define BOOST_ARCHIVE_TMPDIR_HPP
sl@0
     3
sl@0
     4
// MS compatible compilers support #pragma once
sl@0
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
sl@0
     6
# pragma once
sl@0
     7
#endif
sl@0
     8
sl@0
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
sl@0
    10
// tmpdir.hpp:
sl@0
    11
sl@0
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
sl@0
    13
// Use, modification and distribution is subject to the Boost Software
sl@0
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
    15
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    16
sl@0
    17
//  See http://www.boost.org for updates, documentation, and revision history.
sl@0
    18
sl@0
    19
#include <cstdlib> // getenv
sl@0
    20
#include <cassert>
sl@0
    21
sl@0
    22
#include <boost/config.hpp>
sl@0
    23
#ifdef BOOST_NO_STDC_NAMESPACE
sl@0
    24
namespace std {
sl@0
    25
    using ::getenv;
sl@0
    26
}
sl@0
    27
#endif
sl@0
    28
sl@0
    29
namespace boost {
sl@0
    30
namespace archive {
sl@0
    31
sl@0
    32
inline char * tmpdir(){
sl@0
    33
    char *dirname;
sl@0
    34
    dirname = std::getenv("TMP");
sl@0
    35
    if(NULL == dirname)
sl@0
    36
        dirname = std::getenv("TMPDIR");
sl@0
    37
    if(NULL == dirname)
sl@0
    38
        dirname = std::getenv("TEMP");
sl@0
    39
    if(NULL == dirname){
sl@0
    40
        //assert(false); // no temp directory found
sl@0
    41
        dirname = ".";
sl@0
    42
    }
sl@0
    43
    return dirname;
sl@0
    44
}
sl@0
    45
sl@0
    46
} // archive
sl@0
    47
} // boost
sl@0
    48
sl@0
    49
#endif // BOOST_ARCHIVE_TMPDIR_HPP