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

Unified Diff: base/files/file_util_mac.mm

Issue 2713293002: Allow $TMPDIR to set temporary directory on OS X. (Closed)
Patch Set: missing include 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') | chrome/browser/file_select_helper_mac.mm » ('J')
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..8c97aec9803fc98aac8a448a89dae5876b3f4909 100644
--- a/base/files/file_util_mac.mm
+++ b/base/files/file_util_mac.mm
@@ -23,7 +23,13 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
}
bool GetTempDir(base::FilePath* path) {
- NSString* tmp = NSTemporaryDirectory();
+ // In order to facilitate hermetic runs on OS X, first check $TMPDIR
Mark Mentovai 2017/02/28 21:59:21 “first check” makes it sound like TMPDIR might not
iannucci 2017/03/01 02:22:21 Actually now that I've thought about it a bit more
+ NSProcessInfo* procInfo = [NSProcessInfo processInfo];
Mark Mentovai 2017/02/28 21:59:20 Meh. Just do #include <stdlib.h> const char* e
iannucci 2017/03/01 02:22:21 That was actually my first instinct, but I wasn't
+ NSString* tmp = [[procInfo environment] objectForKey: @"TMPDIR"];
+ if (tmp == nil) {
+ // Then fallback to the immutable NSTemporaryDirectory value.
Nico 2017/02/27 01:16:20 nit: "fallback" is a noun, "fall back" is the verb
Mark Mentovai 2017/02/28 21:59:20 Fix this :)
iannucci 2017/03/01 02:22:21 Done.
+ tmp = NSTemporaryDirectory();
+ }
if (tmp == nil)
return false;
*path = base::mac::NSStringToFilePath(tmp);
« no previous file with comments | « no previous file | chrome/browser/file_select_helper_mac.mm » ('j') | chrome/browser/file_select_helper_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698