Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: base/files/file_util_mac.mm

Issue 2713293002: Allow $TMPDIR to set temporary directory on OS X. (Closed)
Patch Set: Fix typo Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/file_select_helper_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5a99aa0e81de2e19110872cc168e53b93555d0c5 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>
#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 macOS, 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;
« no previous file with comments | « no previous file | chrome/browser/file_select_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698