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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "chrome/installer/util/logging_installer.h" | 7 #include "chrome/installer/util/logging_installer.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 const int file_flags = base::PLATFORM_FILE_OPEN | | 40 const int file_flags = base::PLATFORM_FILE_OPEN | |
41 base::PLATFORM_FILE_READ | | 41 base::PLATFORM_FILE_READ | |
42 base::PLATFORM_FILE_SHARE_DELETE | | 42 base::PLATFORM_FILE_SHARE_DELETE | |
43 base::PLATFORM_FILE_DELETE_ON_CLOSE; | 43 base::PLATFORM_FILE_DELETE_ON_CLOSE; |
44 base::win::ScopedHandle old_log_file( | 44 base::win::ScopedHandle old_log_file( |
45 base::CreatePlatformFile(log_file, file_flags, NULL, NULL)); | 45 base::CreatePlatformFile(log_file, file_flags, NULL, NULL)); |
46 | 46 |
47 if (old_log_file.IsValid()) { | 47 if (old_log_file.IsValid()) { |
48 result = LOGFILE_DELETED; | 48 result = LOGFILE_DELETED; |
49 base::FilePath tmp_log(log_file.value() + FILE_PATH_LITERAL(".tmp")); | 49 base::FilePath tmp_log(log_file.value() + FILE_PATH_LITERAL(".tmp")); |
50 // Note that file_util::Move will attempt to replace existing files. | 50 // Note that base::Move will attempt to replace existing files. |
51 if (file_util::Move(log_file, tmp_log)) { | 51 if (base::Move(log_file, tmp_log)) { |
52 int64 offset = log_size - kTruncatedInstallerLogFileSize; | 52 int64 offset = log_size - kTruncatedInstallerLogFileSize; |
53 std::string old_log_data(kTruncatedInstallerLogFileSize, 0); | 53 std::string old_log_data(kTruncatedInstallerLogFileSize, 0); |
54 int bytes_read = base::ReadPlatformFile(old_log_file, | 54 int bytes_read = base::ReadPlatformFile(old_log_file, |
55 offset, | 55 offset, |
56 &old_log_data[0], | 56 &old_log_data[0], |
57 kTruncatedInstallerLogFileSize); | 57 kTruncatedInstallerLogFileSize); |
58 if (bytes_read > 0 && | 58 if (bytes_read > 0 && |
59 (bytes_read == file_util::WriteFile(log_file, | 59 (bytes_read == file_util::WriteFile(log_file, |
60 &old_log_data[0], | 60 &old_log_data[0], |
61 bytes_read) || | 61 bytes_read) || |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 base::FilePath log_path; | 124 base::FilePath log_path; |
125 if (PathService::Get(base::DIR_TEMP, &log_path)) { | 125 if (PathService::Get(base::DIR_TEMP, &log_path)) { |
126 log_path = log_path.Append(log_filename); | 126 log_path = log_path.Append(log_filename); |
127 return log_path; | 127 return log_path; |
128 } else { | 128 } else { |
129 return base::FilePath(log_filename); | 129 return base::FilePath(log_filename); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 } // namespace installer | 133 } // namespace installer |
OLD | NEW |