| OLD | NEW |
| (Empty) |
| 1 // Copyright 2007-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 // Simple tool to read the stamped tag inside a binary. | |
| 17 | |
| 18 #include <Windows.h> | |
| 19 #include <stdio.h> | |
| 20 #include "base/scoped_ptr.h" | |
| 21 #include "omaha/common/file.h" | |
| 22 #include "omaha/common/extractor.h" | |
| 23 | |
| 24 int _tmain(int argc, TCHAR* argv[]) { | |
| 25 if (argc != 2) { | |
| 26 _tprintf(_T("Incorrect number of arguments!\n")); | |
| 27 _tprintf(_T("Usage: ReadTag <tagged_file>\n")); | |
| 28 return -1; | |
| 29 } | |
| 30 | |
| 31 const TCHAR* file = argv[1]; | |
| 32 if (!omaha::File::Exists(file)) { | |
| 33 _tprintf(_T("File \"%s\" not found"), file); | |
| 34 return -1; | |
| 35 } | |
| 36 | |
| 37 omaha::TagExtractor ext; | |
| 38 if (!ext.OpenFile(file)) { | |
| 39 _tprintf(_T("Could not open file \"%s\""), file); | |
| 40 return -1; | |
| 41 } | |
| 42 | |
| 43 int len = 0; | |
| 44 if (!ext.ExtractTag(NULL, &len)) { | |
| 45 _tprintf(_T("Extract tag failed.")); | |
| 46 return -1; | |
| 47 } | |
| 48 | |
| 49 scoped_array<char> buffer(new char[len]); | |
| 50 if (!ext.ExtractTag(buffer.get(), &len)) { | |
| 51 _tprintf(_T("Extract tag failed.")); | |
| 52 return -1; | |
| 53 } | |
| 54 | |
| 55 printf("Tag = '%s'", buffer); | |
| 56 return 0; | |
| 57 } | |
| OLD | NEW |