Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <propvarutil.h> | 8 #include <propvarutil.h> |
| 9 #include <psapi.h> | 9 #include <psapi.h> |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 // trailing slash. We duplicate this here, but it shouldn't be necessary | 551 // trailing slash. We duplicate this here, but it shouldn't be necessary |
| 552 // when everyone is using the appropriate FilePath APIs. | 552 // when everyone is using the appropriate FilePath APIs. |
| 553 *path = FilePath(temp_path).StripTrailingSeparators(); | 553 *path = FilePath(temp_path).StripTrailingSeparators(); |
| 554 return true; | 554 return true; |
| 555 } | 555 } |
| 556 | 556 |
| 557 bool GetShmemTempDir(FilePath* path) { | 557 bool GetShmemTempDir(FilePath* path) { |
| 558 return GetTempDir(path); | 558 return GetTempDir(path); |
| 559 } | 559 } |
| 560 | 560 |
| 561 FilePath GetHomeDir() { | |
|
jar (doing other things)
2011/04/21 01:03:50
I don't think this is a good source of entropy. .
Jói
2011/04/21 19:50:33
2011/04/21 01:03:50, jar wrote:
| |
| 562 wchar_t temp_path[MAX_PATH + 1]; | |
| 563 HRESULT hr = ::SHGetFolderPath( | |
| 564 NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, temp_path); | |
| 565 // No error handling should be necessary for CSIDL_PROFILE; it must | |
| 566 // always exist (after all, we store Chrome data in a subdirectory of it) | |
| 567 // and it is not invalid. Use a hard CHECK to make sure we know if this | |
| 568 // assumption is broken in the wild. | |
| 569 CHECK(SUCCEEDED(hr)); | |
| 570 | |
| 571 return FilePath(temp_path); | |
| 572 } | |
| 573 | |
| 561 bool CreateTemporaryFile(FilePath* path) { | 574 bool CreateTemporaryFile(FilePath* path) { |
| 562 base::ThreadRestrictions::AssertIOAllowed(); | 575 base::ThreadRestrictions::AssertIOAllowed(); |
| 563 | 576 |
| 564 FilePath temp_file; | 577 FilePath temp_file; |
| 565 | 578 |
| 566 if (!GetTempDir(path)) | 579 if (!GetTempDir(path)) |
| 567 return false; | 580 return false; |
| 568 | 581 |
| 569 if (CreateTemporaryFileInDir(*path, &temp_file)) { | 582 if (CreateTemporaryFileInDir(*path, &temp_file)) { |
| 570 *path = temp_file; | 583 *path = temp_file; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1162 uint8 unused = *(touch + offset); | 1175 uint8 unused = *(touch + offset); |
| 1163 offset += step_size; | 1176 offset += step_size; |
| 1164 } | 1177 } |
| 1165 FreeLibrary(dll_module); | 1178 FreeLibrary(dll_module); |
| 1166 } | 1179 } |
| 1167 | 1180 |
| 1168 return true; | 1181 return true; |
| 1169 } | 1182 } |
| 1170 | 1183 |
| 1171 } // namespace file_util | 1184 } // namespace file_util |
| OLD | NEW |