| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/installer/util/lzma_util.h" | 5 #include "chrome/installer/util/lzma_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 | 9 |
| 10 extern "C" { | 10 extern "C" { |
| 11 #include "third_party/lzma_sdk/Archive/7z/7zExtract.h" | 11 #include "third_party/lzma_sdk/Archive/7z/7zExtract.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 std::wstring directory = file_util::GetDirectoryFromPath(wfileName); | 142 std::wstring directory = file_util::GetDirectoryFromPath(wfileName); |
| 143 file_util::CreateDirectory(directory); | 143 file_util::CreateDirectory(directory); |
| 144 | 144 |
| 145 hFile = CreateFile(wfileName.c_str(), GENERIC_WRITE, 0, NULL, | 145 hFile = CreateFile(wfileName.c_str(), GENERIC_WRITE, 0, NULL, |
| 146 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | 146 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); |
| 147 if (hFile == INVALID_HANDLE_VALUE) { | 147 if (hFile == INVALID_HANDLE_VALUE) { |
| 148 ret = GetLastError(); | 148 ret = GetLastError(); |
| 149 break; | 149 break; |
| 150 } | 150 } |
| 151 | 151 |
| 152 WriteFile(hFile, outBuffer + offset, (DWORD) outSizeProcessed, | 152 if ((!WriteFile(hFile, outBuffer + offset, (DWORD) outSizeProcessed, |
| 153 &written, NULL); | 153 &written, NULL)) || |
| 154 if (written != outSizeProcessed) { | 154 (written != outSizeProcessed)) { |
| 155 ret = GetLastError(); | 155 ret = GetLastError(); |
| 156 CloseHandle(hFile); | 156 CloseHandle(hFile); |
| 157 break; | 157 break; |
| 158 } | 158 } |
| 159 | 159 |
| 160 if (f->IsLastWriteTimeDefined) { | 160 if (f->IsLastWriteTimeDefined) { |
| 161 if (!SetFileTime(hFile, NULL, NULL, | 161 if (!SetFileTime(hFile, NULL, NULL, |
| 162 (const FILETIME *)&(f->LastWriteTime))) { | 162 (const FILETIME *)&(f->LastWriteTime))) { |
| 163 ret = GetLastError(); | 163 ret = GetLastError(); |
| 164 CloseHandle(hFile); | 164 CloseHandle(hFile); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 175 SzArDbExFree(&db, allocImp.Free); | 175 SzArDbExFree(&db, allocImp.Free); |
| 176 return ret; | 176 return ret; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void LzmaUtil::CloseArchive() { | 179 void LzmaUtil::CloseArchive() { |
| 180 CloseHandle(archive_handle_); | 180 CloseHandle(archive_handle_); |
| 181 archive_handle_ = NULL; | 181 archive_handle_ = NULL; |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace installer | 184 } // namespace installer |
| OLD | NEW |