Chromium Code Reviews| Index: base/files/file_util_mac.mm |
| diff --git a/base/files/file_util_mac.mm b/base/files/file_util_mac.mm |
| index e9c6c651593571ca425c1a012db8ec76722938ff..55187a8ca443e5306b178e8c1d9ca644e3c11fd1 100644 |
| --- a/base/files/file_util_mac.mm |
| +++ b/base/files/file_util_mac.mm |
| @@ -4,8 +4,9 @@ |
| #include "base/files/file_util.h" |
| -#include <copyfile.h> |
| #import <Foundation/Foundation.h> |
| +#include <copyfile.h> |
| +#include <stdlib.h> |
|
iannucci
2017/03/01 02:23:19
`git cl format` made me do this
|
| #include "base/files/file_path.h" |
| #include "base/mac/foundation_util.h" |
| @@ -23,6 +24,15 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) { |
| } |
| bool GetTempDir(base::FilePath* path) { |
| + // In order to facilitate hermetic runs on OS X, first check $TMPDIR. |
| + // NOTE: $TMPDIR is ALMOST ALWAYS set on macOS (unless the user un-set it). |
| + const char* env_tmpdir = getenv("TMPDIR"); |
| + if (env_tmpdir) { |
| + *path = base::FilePath(env_tmpdir); |
| + return true; |
| + } |
| + |
| + // If we didn't find it, fall back to the native function. |
| NSString* tmp = NSTemporaryDirectory(); |
| if (tmp == nil) |
| return false; |