| OLD | NEW |
| (Empty) |
| 1 // Copyright 2006-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 | |
| 17 #ifndef OMAHA_MI_EXE_STUB_TAR_H_ | |
| 18 #define OMAHA_MI_EXE_STUB_TAR_H_ | |
| 19 | |
| 20 #include <tchar.h> | |
| 21 #include <atlsimpcoll.h> | |
| 22 #include <atlstr.h> | |
| 23 #include <windows.h> | |
| 24 | |
| 25 namespace omaha { | |
| 26 | |
| 27 static const int kNameSize = 100; | |
| 28 | |
| 29 typedef struct { | |
| 30 char name[kNameSize]; | |
| 31 char mode[8]; | |
| 32 char uid[8]; | |
| 33 char gid[8]; | |
| 34 char size[12]; | |
| 35 char mtime[12]; | |
| 36 char chksum[8]; | |
| 37 char typeflag; | |
| 38 char linkname[kNameSize]; | |
| 39 char magic[6]; | |
| 40 char version[2]; | |
| 41 char uname[32]; | |
| 42 char gname[32]; | |
| 43 char devmajor[8]; | |
| 44 char devminor[8]; | |
| 45 char prefix[155]; | |
| 46 char dummy[12]; // make it exactly 512 bytes | |
| 47 } USTARHeader; | |
| 48 | |
| 49 // Supports untarring of files from a tar-format archive. Pretty minimal; | |
| 50 // doesn't work with everything in the USTAR format. | |
| 51 class Tar { | |
| 52 public: | |
| 53 Tar(const CString& target_dir, HANDLE file_handle, bool delete_when_done); | |
| 54 ~Tar(); | |
| 55 | |
| 56 typedef void (*TarFileCallback)(void* context, const TCHAR* filename); | |
| 57 | |
| 58 void SetCallback(TarFileCallback callback, void* callback_context) { | |
| 59 callback_ = callback; | |
| 60 callback_context_ = callback_context; | |
| 61 } | |
| 62 | |
| 63 // Extracts all files in archive to directory specified in constructor. | |
| 64 // Directory must exist. Returns true if successful. | |
| 65 bool ExtractToDir(); | |
| 66 | |
| 67 private: | |
| 68 HANDLE file_handle_; | |
| 69 CString target_directory_name_; | |
| 70 bool delete_when_done_; | |
| 71 CSimpleArray<CString> files_to_delete_; | |
| 72 TarFileCallback callback_; | |
| 73 void* callback_context_; | |
| 74 | |
| 75 bool ExtractOneFile(bool* done); | |
| 76 }; | |
| 77 | |
| 78 } // namespace omaha | |
| 79 | |
| 80 #endif // OMAHA_MI_EXE_STUB_TAR_H_ | |
| OLD | NEW |