mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
<rdar://problem/13477190> On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR for the system temporary directory.
The DARWIN_USER_TEMP_DIR and DARWIN_USER_CACHE_DIR configuration settings are more idiomatic for Darwin than the TMPDIR environment variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c91b5e197b
commit
b0b5bde018
@ -18,6 +18,9 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using llvm::StringRef;
|
using llvm::StringRef;
|
||||||
@ -493,6 +496,27 @@ bool is_separator(char value) {
|
|||||||
void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result) {
|
void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result) {
|
||||||
result.clear();
|
result.clear();
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
|
||||||
|
int ConfName = erasedOnReboot? _CS_DARWIN_USER_TEMP_DIR
|
||||||
|
: _CS_DARWIN_USER_CACHE_DIR;
|
||||||
|
size_t ConfLen = confstr(ConfName, 0, 0);
|
||||||
|
if (ConfLen > 0) {
|
||||||
|
do {
|
||||||
|
result.resize(ConfLen);
|
||||||
|
ConfLen = confstr(ConfName, result.data(), result.size());
|
||||||
|
} while (ConfLen > 0 && ConfLen != result.size());
|
||||||
|
|
||||||
|
if (ConfLen > 0) {
|
||||||
|
assert(result.back() == 0);
|
||||||
|
result.pop_back();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.clear();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check whether the temporary directory is specified by an environment
|
// Check whether the temporary directory is specified by an environment
|
||||||
// variable.
|
// variable.
|
||||||
const char *EnvironmentVariable;
|
const char *EnvironmentVariable;
|
||||||
|
Loading…
Reference in New Issue
Block a user