OLD | NEW |
1 // Copyright (c) 2009 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 #ifndef CHROME_INSTALLER_UTIL_LZMA_UTIL_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_LZMA_UTIL_H_ |
6 #define CHROME_INSTALLER_UTIL_LZMA_UTIL_H_ | 6 #define CHROME_INSTALLER_UTIL_LZMA_UTIL_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <stdint.h> |
9 | 10 |
10 #include <set> | 11 #include <set> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/basictypes.h" | 14 #include "base/macros.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class FilePath; | 17 class FilePath; |
17 } | 18 } |
18 | 19 |
19 // This is a utility class that acts as a wrapper around LZMA SDK library | 20 // This is a utility class that acts as a wrapper around LZMA SDK library |
20 class LzmaUtil { | 21 class LzmaUtil { |
21 public: | 22 public: |
22 // Utility method that does the job of calling OpenArchive(), UnPack() | 23 // Utility method that does the job of calling OpenArchive(), UnPack() |
23 // and CloseArchive() in order. Returns error code (NO_ERROR if successful). | 24 // and CloseArchive() in order. Returns error code (NO_ERROR if successful). |
24 static int32 UnPackArchive(const std::wstring& archive, | 25 static int32_t UnPackArchive(const std::wstring& archive, |
25 const std::wstring& output_dir, | 26 const std::wstring& output_dir, |
26 std::wstring* output_file); | 27 std::wstring* output_file); |
27 | 28 |
28 LzmaUtil(); | 29 LzmaUtil(); |
29 ~LzmaUtil(); | 30 ~LzmaUtil(); |
30 | 31 |
31 DWORD OpenArchive(const std::wstring& archivePath); | 32 DWORD OpenArchive(const std::wstring& archivePath); |
32 | 33 |
33 // Unpacks the archive to the given location | 34 // Unpacks the archive to the given location |
34 DWORD UnPack(const std::wstring& location); | 35 DWORD UnPack(const std::wstring& location); |
35 | 36 |
36 // Unpacks the archive to the given location and returns the last file | 37 // Unpacks the archive to the given location and returns the last file |
37 // extracted from archive. |single_file| is set to true iff only a single | 38 // extracted from archive. |single_file| is set to true iff only a single |
38 // file is extracted from archive. | 39 // file is extracted from archive. |
39 DWORD UnPack(const std::wstring& location, | 40 DWORD UnPack(const std::wstring& location, |
40 std::wstring* output_file); | 41 std::wstring* output_file); |
41 | 42 |
42 void CloseArchive(); | 43 void CloseArchive(); |
43 | 44 |
44 protected: | 45 protected: |
45 bool CreateDirectory(const base::FilePath& dir); | 46 bool CreateDirectory(const base::FilePath& dir); |
46 | 47 |
47 private: | 48 private: |
48 HANDLE archive_handle_; | 49 HANDLE archive_handle_; |
49 std::set<std::wstring> directories_created_; | 50 std::set<std::wstring> directories_created_; |
50 | 51 |
51 DISALLOW_COPY_AND_ASSIGN(LzmaUtil); | 52 DISALLOW_COPY_AND_ASSIGN(LzmaUtil); |
52 }; | 53 }; |
53 | 54 |
54 #endif // CHROME_INSTALLER_UTIL_LZMA_UTIL_H_ | 55 #endif // CHROME_INSTALLER_UTIL_LZMA_UTIL_H_ |
OLD | NEW |