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

Side by Side Diff: base/nix/xdg_util.cc

Issue 93263002: Move some more file utils to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « base/nix/mime_util_xdg.cc ('k') | base/os_compat_android_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/nix/xdg_util.h" 5 #include "base/nix/xdg_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 13 matching lines...) Expand all
24 const char kDotConfigDir[] = ".config"; 24 const char kDotConfigDir[] = ".config";
25 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; 25 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
26 26
27 FilePath GetXDGDirectory(Environment* env, const char* env_name, 27 FilePath GetXDGDirectory(Environment* env, const char* env_name,
28 const char* fallback_dir) { 28 const char* fallback_dir) {
29 FilePath path; 29 FilePath path;
30 std::string env_value; 30 std::string env_value;
31 if (env->GetVar(env_name, &env_value) && !env_value.empty()) 31 if (env->GetVar(env_name, &env_value) && !env_value.empty())
32 path = FilePath(env_value); 32 path = FilePath(env_value);
33 else 33 else
34 path = file_util::GetHomeDir().Append(fallback_dir); 34 path = GetHomeDir().Append(fallback_dir);
35 return path.StripTrailingSeparators(); 35 return path.StripTrailingSeparators();
36 } 36 }
37 37
38 FilePath GetXDGUserDirectory(const char* dir_name, const char* fallback_dir) { 38 FilePath GetXDGUserDirectory(const char* dir_name, const char* fallback_dir) {
39 FilePath path; 39 FilePath path;
40 char* xdg_dir = xdg_user_dir_lookup(dir_name); 40 char* xdg_dir = xdg_user_dir_lookup(dir_name);
41 if (xdg_dir) { 41 if (xdg_dir) {
42 path = FilePath(xdg_dir); 42 path = FilePath(xdg_dir);
43 free(xdg_dir); 43 free(xdg_dir);
44 } else { 44 } else {
45 path = file_util::GetHomeDir().Append(fallback_dir); 45 path = GetHomeDir().Append(fallback_dir);
46 } 46 }
47 return path.StripTrailingSeparators(); 47 return path.StripTrailingSeparators();
48 } 48 }
49 49
50 DesktopEnvironment GetDesktopEnvironment(Environment* env) { 50 DesktopEnvironment GetDesktopEnvironment(Environment* env) {
51 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. 51 // XDG_CURRENT_DESKTOP is the newest standard circa 2012.
52 std::string xdg_current_desktop; 52 std::string xdg_current_desktop;
53 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { 53 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) {
54 // Not all desktop environments set this env var as of this writing. 54 // Not all desktop environments set this env var as of this writing.
55 if (xdg_current_desktop == "Unity") 55 if (xdg_current_desktop == "Unity")
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 return NULL; 107 return NULL;
108 } 108 }
109 109
110 const char* GetDesktopEnvironmentName(Environment* env) { 110 const char* GetDesktopEnvironmentName(Environment* env) {
111 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); 111 return GetDesktopEnvironmentName(GetDesktopEnvironment(env));
112 } 112 }
113 113
114 } // namespace nix 114 } // namespace nix
115 } // namespace base 115 } // namespace base
OLDNEW
« no previous file with comments | « base/nix/mime_util_xdg.cc ('k') | base/os_compat_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698