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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); | 549 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); |
550 if (path_len >= MAX_PATH || path_len <= 0) | 550 if (path_len >= MAX_PATH || path_len <= 0) |
551 return false; | 551 return false; |
552 // TODO(evanm): the old behavior of this function was to always strip the | 552 // TODO(evanm): the old behavior of this function was to always strip the |
553 // trailing slash. We duplicate this here, but it shouldn't be necessary | 553 // trailing slash. We duplicate this here, but it shouldn't be necessary |
554 // when everyone is using the appropriate FilePath APIs. | 554 // when everyone is using the appropriate FilePath APIs. |
555 *path = FilePath(temp_path).StripTrailingSeparators(); | 555 *path = FilePath(temp_path).StripTrailingSeparators(); |
556 return true; | 556 return true; |
557 } | 557 } |
558 | 558 |
559 bool GetShmemTempDir(FilePath* path) { | 559 bool GetShmemTempDir(FilePath* path, bool executable) { |
560 return GetTempDir(path); | 560 return GetTempDir(path); |
561 } | 561 } |
562 | 562 |
563 bool CreateTemporaryFile(FilePath* path) { | 563 bool CreateTemporaryFile(FilePath* path) { |
564 base::ThreadRestrictions::AssertIOAllowed(); | 564 base::ThreadRestrictions::AssertIOAllowed(); |
565 | 565 |
566 FilePath temp_file; | 566 FilePath temp_file; |
567 | 567 |
568 if (!GetTempDir(path)) | 568 if (!GetTempDir(path)) |
569 return false; | 569 return false; |
570 | 570 |
571 if (CreateTemporaryFileInDir(*path, &temp_file)) { | 571 if (CreateTemporaryFileInDir(*path, &temp_file)) { |
572 *path = temp_file; | 572 *path = temp_file; |
573 return true; | 573 return true; |
574 } | 574 } |
575 | 575 |
576 return false; | 576 return false; |
577 } | 577 } |
578 | 578 |
579 FILE* CreateAndOpenTemporaryShmemFile(FilePath* path) { | 579 FILE* CreateAndOpenTemporaryShmemFile(FilePath* path, bool executable) { |
580 base::ThreadRestrictions::AssertIOAllowed(); | 580 base::ThreadRestrictions::AssertIOAllowed(); |
581 return CreateAndOpenTemporaryFile(path); | 581 return CreateAndOpenTemporaryFile(path); |
582 } | 582 } |
583 | 583 |
584 // On POSIX we have semantics to create and open a temporary file | 584 // On POSIX we have semantics to create and open a temporary file |
585 // atomically. | 585 // atomically. |
586 // TODO(jrg): is there equivalent call to use on Windows instead of | 586 // TODO(jrg): is there equivalent call to use on Windows instead of |
587 // going 2-step? | 587 // going 2-step? |
588 FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { | 588 FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) { |
589 base::ThreadRestrictions::AssertIOAllowed(); | 589 base::ThreadRestrictions::AssertIOAllowed(); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 uint8 unused = *(touch + offset); | 1160 uint8 unused = *(touch + offset); |
1161 offset += step_size; | 1161 offset += step_size; |
1162 } | 1162 } |
1163 FreeLibrary(dll_module); | 1163 FreeLibrary(dll_module); |
1164 } | 1164 } |
1165 | 1165 |
1166 return true; | 1166 return true; |
1167 } | 1167 } |
1168 | 1168 |
1169 } // namespace file_util | 1169 } // namespace file_util |
OLD | NEW |