summaryrefslogtreecommitdiffstats
path: root/base/base_paths_win.cc
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 16:50:03 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 16:50:03 +0000
commit4792a2655593ad5fcb436f8b88184540c570a46e (patch)
tree11d176cb8cbc9f32c79a91433193eb0c7ab018b7 /base/base_paths_win.cc
parentaa075e7d76093df41e33c6866c48080f49daedbd (diff)
downloadchromium_src-4792a2655593ad5fcb436f8b88184540c570a46e.zip
chromium_src-4792a2655593ad5fcb436f8b88184540c570a46e.tar.gz
chromium_src-4792a2655593ad5fcb436f8b88184540c570a46e.tar.bz2
Move more code to using FilePath.
Review URL: http://codereview.chromium.org/11252 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/base_paths_win.cc')
-rw-r--r--base/base_paths_win.cc42
1 files changed, 23 insertions, 19 deletions
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
index ca87e1b..3d402c3 100644
--- a/base/base_paths_win.cc
+++ b/base/base_paths_win.cc
@@ -7,6 +7,7 @@
#include <windows.h>
#include <shlobj.h>
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/win_util.h"
@@ -16,7 +17,7 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
namespace base {
-bool PathProviderWin(int key, std::wstring* result) {
+bool PathProviderWin(int key, FilePath* result) {
// We need to go compute the value. It would be nice to support paths with
// names longer than MAX_PATH, but the system functions don't seem to be
@@ -26,57 +27,58 @@ bool PathProviderWin(int key, std::wstring* result) {
wchar_t system_buffer[MAX_PATH];
system_buffer[0] = 0;
- std::wstring cur;
+ FilePath cur;
+ std::wstring wstring_path;
switch (key) {
case base::FILE_EXE:
GetModuleFileName(NULL, system_buffer, MAX_PATH);
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::FILE_MODULE: {
// the resource containing module is assumed to be the one that
// this code lives in, whether that's a dll or exe
HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
GetModuleFileName(this_module, system_buffer, MAX_PATH);
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
}
case base::DIR_WINDOWS:
GetWindowsDirectory(system_buffer, MAX_PATH);
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_SYSTEM:
GetSystemDirectory(system_buffer, MAX_PATH);
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_PROGRAM_FILES:
if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
SHGFP_TYPE_CURRENT, system_buffer)))
return false;
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_IE_INTERNET_CACHE:
if (FAILED(SHGetFolderPath(NULL, CSIDL_INTERNET_CACHE, NULL,
SHGFP_TYPE_CURRENT, system_buffer)))
return false;
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_COMMON_START_MENU:
if (FAILED(SHGetFolderPath(NULL, CSIDL_COMMON_PROGRAMS, NULL,
SHGFP_TYPE_CURRENT, system_buffer)))
return false;
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_START_MENU:
if (FAILED(SHGetFolderPath(NULL, CSIDL_PROGRAMS, NULL,
SHGFP_TYPE_CURRENT, system_buffer)))
return false;
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_APP_DATA:
if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
system_buffer)))
return false;
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_LOCAL_APP_DATA_LOW:
if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) {
@@ -86,28 +88,30 @@ bool PathProviderWin(int key, std::wstring* result) {
if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
system_buffer)))
return false;
- cur = system_buffer;
- file_util::UpOneDirectory(&cur);
- file_util::AppendToPath(&cur, L"LocalLow");
+ wstring_path = system_buffer;
+ file_util::UpOneDirectory(&wstring_path);
+ file_util::AppendToPath(&wstring_path, L"LocalLow");
+ cur = FilePath(wstring_path);
break;
case base::DIR_LOCAL_APP_DATA:
if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
SHGFP_TYPE_CURRENT, system_buffer)))
return false;
- cur = system_buffer;
+ cur = FilePath(system_buffer);
break;
case base::DIR_SOURCE_ROOT:
// On Windows, unit tests execute two levels deep from the source root.
// For example: chrome/{Debug|Release}/ui_tests.exe
- PathService::Get(base::DIR_EXE, &cur);
- file_util::UpOneDirectory(&cur);
- file_util::UpOneDirectory(&cur);
+ PathService::Get(base::DIR_EXE, &wstring_path);
+ file_util::UpOneDirectory(&wstring_path);
+ file_util::UpOneDirectory(&wstring_path);
+ cur = FilePath(wstring_path);
break;
default:
return false;
}
- result->swap(cur);
+ *result = cur;
return true;
}