OLD | NEW |
---|---|
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/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <psapi.h> | 8 #include <psapi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 // trailing slash. We duplicate this here, but it shouldn't be necessary | 251 // trailing slash. We duplicate this here, but it shouldn't be necessary |
252 // when everyone is using the appropriate FilePath APIs. | 252 // when everyone is using the appropriate FilePath APIs. |
253 *path = FilePath(temp_path).StripTrailingSeparators(); | 253 *path = FilePath(temp_path).StripTrailingSeparators(); |
254 return true; | 254 return true; |
255 } | 255 } |
256 | 256 |
257 bool GetShmemTempDir(bool executable, FilePath* path) { | 257 bool GetShmemTempDir(bool executable, FilePath* path) { |
258 return GetTempDir(path); | 258 return GetTempDir(path); |
259 } | 259 } |
260 | 260 |
261 FilePath GetHomeDir() { | |
262 char16 result[MAX_PATH]; | |
263 if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, | |
264 result)) && | |
265 result[0]) | |
266 return FilePath(result); | |
benwells
2014/02/18 23:14:40
Nit: curlies around block as if spans multiple lin
| |
267 | |
268 // Fall back to the temporary directory on failure. | |
269 FilePath temp; | |
270 if (GetTempDir(&temp)) | |
271 return temp; | |
272 | |
273 // Last resort. | |
274 return FilePath(L"C:\\"); | |
275 } | |
276 | |
261 bool CreateTemporaryFile(FilePath* path) { | 277 bool CreateTemporaryFile(FilePath* path) { |
262 ThreadRestrictions::AssertIOAllowed(); | 278 ThreadRestrictions::AssertIOAllowed(); |
263 | 279 |
264 FilePath temp_file; | 280 FilePath temp_file; |
265 | 281 |
266 if (!GetTempDir(path)) | 282 if (!GetTempDir(path)) |
267 return false; | 283 return false; |
268 | 284 |
269 if (CreateTemporaryFileInDir(*path, &temp_file)) { | 285 if (CreateTemporaryFileInDir(*path, &temp_file)) { |
270 *path = temp_file; | 286 *path = temp_file; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 // Like Move, this function is not transactional, so we just | 803 // Like Move, this function is not transactional, so we just |
788 // leave the copied bits behind if deleting from_path fails. | 804 // leave the copied bits behind if deleting from_path fails. |
789 // If to_path exists previously then we have already overwritten | 805 // If to_path exists previously then we have already overwritten |
790 // it by now, we don't get better off by deleting the new bits. | 806 // it by now, we don't get better off by deleting the new bits. |
791 } | 807 } |
792 return false; | 808 return false; |
793 } | 809 } |
794 | 810 |
795 } // namespace internal | 811 } // namespace internal |
796 } // namespace base | 812 } // namespace base |
OLD | NEW |