| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 result = LOGFILE_DELETED; | 47 result = LOGFILE_DELETED; |
| 48 base::FilePath tmp_log(log_file.value() + FILE_PATH_LITERAL(".tmp")); | 48 base::FilePath tmp_log(log_file.value() + FILE_PATH_LITERAL(".tmp")); |
| 49 // Note that base::Move will attempt to replace existing files. | 49 // Note that base::Move will attempt to replace existing files. |
| 50 if (base::Move(log_file, tmp_log)) { | 50 if (base::Move(log_file, tmp_log)) { |
| 51 int64 offset = log_size - kTruncatedInstallerLogFileSize; | 51 int64 offset = log_size - kTruncatedInstallerLogFileSize; |
| 52 std::string old_log_data(kTruncatedInstallerLogFileSize, 0); | 52 std::string old_log_data(kTruncatedInstallerLogFileSize, 0); |
| 53 int bytes_read = old_log_file.Read(offset, | 53 int bytes_read = old_log_file.Read(offset, |
| 54 &old_log_data[0], | 54 &old_log_data[0], |
| 55 kTruncatedInstallerLogFileSize); | 55 kTruncatedInstallerLogFileSize); |
| 56 if (bytes_read > 0 && | 56 if (bytes_read > 0 && |
| 57 (bytes_read == file_util::WriteFile(log_file, | 57 (bytes_read == base::WriteFile(log_file, &old_log_data[0], |
| 58 &old_log_data[0], | 58 bytes_read) || |
| 59 bytes_read) || | |
| 60 base::PathExists(log_file))) { | 59 base::PathExists(log_file))) { |
| 61 result = LOGFILE_TRUNCATED; | 60 result = LOGFILE_TRUNCATED; |
| 62 } | 61 } |
| 63 } | 62 } |
| 64 } else if (base::DeleteFile(log_file, false)) { | 63 } else if (base::DeleteFile(log_file, false)) { |
| 65 // Couldn't get sufficient access to the log file, optimistically try to | 64 // Couldn't get sufficient access to the log file, optimistically try to |
| 66 // delete it. | 65 // delete it. |
| 67 result = LOGFILE_DELETED; | 66 result = LOGFILE_DELETED; |
| 68 } | 67 } |
| 69 } | 68 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 static const base::FilePath::CharType kLogFilename[] = | 117 static const base::FilePath::CharType kLogFilename[] = |
| 119 FILE_PATH_LITERAL("chrome_installer.log"); | 118 FILE_PATH_LITERAL("chrome_installer.log"); |
| 120 | 119 |
| 121 // Fallback to current directory if getting the temp directory fails. | 120 // Fallback to current directory if getting the temp directory fails. |
| 122 base::FilePath tmp_path; | 121 base::FilePath tmp_path; |
| 123 ignore_result(PathService::Get(base::DIR_TEMP, &tmp_path)); | 122 ignore_result(PathService::Get(base::DIR_TEMP, &tmp_path)); |
| 124 return tmp_path.Append(kLogFilename); | 123 return tmp_path.Append(kLogFilename); |
| 125 } | 124 } |
| 126 | 125 |
| 127 } // namespace installer | 126 } // namespace installer |
| OLD | NEW |