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

Side by Side Diff: tools/TempDir.cpp

Issue 830513004: Simplify skiatest framework. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mtklein comments Created 5 years, 11 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 unified diff | Download patch
« tools/TempDir.h ('K') | « tools/TempDir.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include <stdlib.h>
9
10 #include "TempDir.h"
11
12 #include "SkCommandLineFlags.h"
13 #include "SkOSFile.h"
14
15 DEFINE_string2(tmpDir, t, NULL, "Temp directory to use.");
mtklein 2015/01/18 22:57:55 It doesn't look like anyone sets this flag. So, a
hal.canary 2015/01/20 16:01:52 Done.
16
17 static bool nonempty_string(const char s[]) { return s && s[0]; }
18
19 // Logic borrowed from
20 // https://docs.python.org/2/library/tempfile.html#tempfile.tempdir
mtklein 2015/01/18 22:57:55 Let's not do this. This is way more complicated t
hal.canary 2015/01/20 16:01:52 Done.
21 SkString sk_tools::GetTmpDir() {
22 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0];
23 if (nonempty_string(tmpDir)) {
mtklein 2015/01/18 22:57:55 This seems like a weird way to write if (!FLAGS_t
hal.canary 2015/01/20 16:01:52 Acknowledged.
24 return SkString(tmpDir);
25 }
26
27 const char* const kVariables[] = {"TMPDIR", "TEMP", "TMP"};
mtklein 2015/01/18 22:57:55 Why are we getting so complicated with features no
hal.canary 2015/01/20 16:01:52 Acknowledged.
28 for (size_t i = 0; i < SK_ARRAY_COUNT(kVariables); ++i) {
29 tmpDir = getenv(kVariables[i]);
30 if (nonempty_string(tmpDir)) {
31 return SkString(tmpDir);
32 }
33 }
34
35 #ifdef SK_BUILD_FOR_WIN
36 const char* const kDirectories[] = {
37 "C:\\TEMP", "C:\\TMP", "\\TEMP", "\\TMP"};
38 #else
39 const char* const kDirectories[] = {"/tmp", "/var/tmp", "/usr/tmp"};
40 #endif
41
42 for (size_t i = 0; i < SK_ARRAY_COUNT(kDirectories); ++i) {
43 if (sk_isdir(kDirectories[i])) {
44 return SkString(kDirectories[i]);
45 }
46 }
47 return SkString(".");
mtklein 2015/01/18 22:57:55 This seems like a bad idea. I'd rather return no
hal.canary 2015/01/20 16:01:52 Acknowledged.
48 }
OLDNEW
« tools/TempDir.h ('K') | « tools/TempDir.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698