1 : // Copyright 2014 Google Inc. All Rights Reserved.
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 : // Declares data structures found in archive files.
16 :
17 : #ifndef SYZYGY_AR_AR_COMMON_H_
18 : #define SYZYGY_AR_AR_COMMON_H_
19 :
20 : #include <map>
21 : #include <string>
22 : #include <vector>
23 :
24 : #include "base/time/time.h"
25 : #include "syzygy/common/assertions.h"
26 :
27 : namespace ar {
28 :
29 : extern const size_t kArFileAlignment;
30 : extern const char kArGlobalMagic[8];
31 : extern const char kArFileMagic[2];
32 :
33 : // The buffer object used for reading and writing files to an archive.
34 : typedef std::vector<uint8> DataBuffer;
35 :
36 : // Maps symbols by their name to the index of the archived file containing
37 : // them.
38 : typedef std::map<std::string, uint32> SymbolIndexMap;
39 :
40 : // The global file header.
41 : struct ArGlobalHeader {
42 : char magic[8];
43 : };
44 : COMPILE_ASSERT_IS_POD_OF_SIZE(ArGlobalHeader, 8);
45 :
46 : // The header that prefixes each file that is encoded in the archive.
47 : struct ArFileHeader {
48 : // Name of the field member, with a terminating '/'. If it begins with a
49 : // slash then the following integer is an offset into the filename table.
50 : char name[16];
51 : // Number of seconds since midnight 1 Jan 1970 UTC.
52 : char timestamp[12];
53 : // Blank in MSVS.
54 : char owner_id[6];
55 : // Blank in MSVS.
56 : char group_id[6];
57 : // ST_MODE from _wstat.
58 : char mode[8];
59 : // Size in bytes.
60 : char size[10];
61 : char magic[2];
62 : };
63 : COMPILE_ASSERT_IS_POD_OF_SIZE(ArFileHeader, 60);
64 :
65 : // A parsed version of the archive file header.
66 : struct ParsedArFileHeader {
67 E : ParsedArFileHeader()
68 : : timestamp(), mode(0), size(0) {
69 E : }
70 :
71 : std::string name;
72 : base::Time timestamp;
73 : uint32 mode;
74 : uint64 size;
75 : };
76 :
77 : } // namespace ar
78 :
79 : #endif // SYZYGY_AR_AR_COMMON_H_
|