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/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #include <time.h> | 10 #include <time.h> |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 " failed, error code=" << GetLastError() << | 542 " failed, error code=" << GetLastError() << |
543 " description=" << win_util::FormatLastWin32Error(); | 543 " description=" << win_util::FormatLastWin32Error(); |
544 } else { | 544 } else { |
545 // Didn't write all the bytes. | 545 // Didn't write all the bytes. |
546 LOG(WARNING) << "wrote" << written << " bytes to " << filename << | 546 LOG(WARNING) << "wrote" << written << " bytes to " << filename << |
547 " expected " << size; | 547 " expected " << size; |
548 } | 548 } |
549 return -1; | 549 return -1; |
550 } | 550 } |
551 | 551 |
552 bool RenameFileAndResetSecurityDescriptor( | 552 bool RenameFileAndResetSecurityDescriptor(const FilePath& source_file_path, |
553 const std::wstring& source_file_path, | 553 const FilePath& target_file_path) { |
554 const std::wstring& target_file_path) { | |
555 // The parameters to SHFileOperation must be terminated with 2 NULL chars. | 554 // The parameters to SHFileOperation must be terminated with 2 NULL chars. |
556 std::wstring source = source_file_path; | 555 std::wstring source = source_file_path.value(); |
557 std::wstring target = target_file_path; | 556 std::wstring target = target_file_path.value(); |
558 | 557 |
559 source.append(1, L'\0'); | 558 source.append(1, L'\0'); |
560 target.append(1, L'\0'); | 559 target.append(1, L'\0'); |
561 | 560 |
562 SHFILEOPSTRUCT move_info = {0}; | 561 SHFILEOPSTRUCT move_info = {0}; |
563 move_info.wFunc = FO_MOVE; | 562 move_info.wFunc = FO_MOVE; |
564 move_info.pFrom = source.c_str(); | 563 move_info.pFrom = source.c_str(); |
565 move_info.pTo = target.c_str(); | 564 move_info.pTo = target.c_str(); |
566 move_info.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | | 565 move_info.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | |
567 FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS; | 566 FOF_NOCONFIRMMKDIR | FOF_NOCOPYSECURITYATTRIBS; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 void PathComponents(const std::wstring& path, | 748 void PathComponents(const std::wstring& path, |
750 std::vector<std::wstring>* components) { | 749 std::vector<std::wstring>* components) { |
751 PathComponents(FilePath(path), components); | 750 PathComponents(FilePath(path), components); |
752 } | 751 } |
753 void ReplaceExtension(std::wstring* file_name, const std::wstring& extension) { | 752 void ReplaceExtension(std::wstring* file_name, const std::wstring& extension) { |
754 FilePath path(*file_name); | 753 FilePath path(*file_name); |
755 ReplaceExtension(&path, extension); | 754 ReplaceExtension(&path, extension); |
756 file_name->assign(path.value()); | 755 file_name->assign(path.value()); |
757 } | 756 } |
758 } // namespace file_util | 757 } // namespace file_util |
OLD | NEW |