| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/path_service.h" | 5 #include "base/path_service.h" |
| 6 | 6 |
| 7 #ifdef OS_WIN | 7 #ifdef OS_WIN |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 bool PathService::Override(int key, const std::wstring& path) { | 198 bool PathService::Override(int key, const std::wstring& path) { |
| 199 PathData* path_data = GetPathData(); | 199 PathData* path_data = GetPathData(); |
| 200 DCHECK(path_data); | 200 DCHECK(path_data); |
| 201 DCHECK(key > base::DIR_CURRENT) << "invalid path key"; | 201 DCHECK(key > base::DIR_CURRENT) << "invalid path key"; |
| 202 | 202 |
| 203 std::wstring file_path = path; | 203 std::wstring file_path = path; |
| 204 if (!file_util::AbsolutePath(&file_path)) | 204 if (!file_util::AbsolutePath(&file_path)) |
| 205 return false; | 205 return false; |
| 206 | 206 |
| 207 // make sure the directory exists: | 207 // make sure the directory exists: |
| 208 if (!file_util::PathExists(file_path) && | 208 if (!file_util::CreateDirectory(file_path)) |
| 209 // TODO(darin): what if this path is not that of a directory? | |
| 210 !file_util::CreateDirectory(file_path)) | |
| 211 return false; | 209 return false; |
| 212 | 210 |
| 213 file_util::TrimTrailingSeparator(&file_path); | 211 file_util::TrimTrailingSeparator(&file_path); |
| 214 | 212 |
| 215 AutoLock scoped_lock(path_data->lock); | 213 AutoLock scoped_lock(path_data->lock); |
| 216 path_data->cache[key] = file_path; | 214 path_data->cache[key] = file_path; |
| 217 path_data->overrides.insert(key); | 215 path_data->overrides.insert(key); |
| 218 return true; | 216 return true; |
| 219 } | 217 } |
| 220 | 218 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 244 p = new Provider; | 242 p = new Provider; |
| 245 p->is_static = false; | 243 p->is_static = false; |
| 246 p->func = func; | 244 p->func = func; |
| 247 p->next = path_data->providers; | 245 p->next = path_data->providers; |
| 248 #ifndef NDEBUG | 246 #ifndef NDEBUG |
| 249 p->key_start = key_start; | 247 p->key_start = key_start; |
| 250 p->key_end = key_end; | 248 p->key_end = key_end; |
| 251 #endif | 249 #endif |
| 252 path_data->providers = p; | 250 path_data->providers = p; |
| 253 } | 251 } |
| 254 | |
| OLD | NEW |