温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:X3BLOG 单用户1.0 build80707(ACCESS)源代码
当前文件路径:x3blogAccessBuild80707/SharpZipLib/Tar/TarHeader.cs

1// TarHeader.cs 2
// 3
// Copyright (C) 2001 Mike Krueger 4
// 5
// This program is free software; you can redistribute it and/or 6
// modify it under the terms of the GNU General Public License 7
// as published by the Free Software Foundation; either version 2 8
// of the License, or (at your option) any later version. 9
// 10
// This program is distributed in the hope that it will be useful, 11
// but WITHOUT ANY WARRANTY; without even the implied warranty of 12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13
// GNU General Public License for more details. 14
// 15
// You should have received a copy of the GNU General Public License 16
// along with this program; if not, write to the Free Software 17
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18
// 19
// Linking this library statically or dynamically with other modules is 20
// making a combined work based on this library. Thus, the terms and 21
// conditions of the GNU General Public License cover the whole 22
// combination. 23
// 24
// As a special exception, the copyright holders of this library give you 25
// permission to link this library with independent modules to produce an 26
// executable, regardless of the license terms of these independent 27
// modules, and to copy and distribute the resulting executable under 28
// terms of your choice, provided that you also meet, for each linked 29
// independent module, the terms and conditions of the license of that 30
// module. An independent module is a module which is not derived from 31
// or based on this library. If you modify this library, you may extend 32
// this exception to your version of the library, but you are not 33
// obligated to do so. If you do not wish to do so, delete this 34
// exception statement from your version. 35
36
37
/* The tar format and its POSIX successor PAX have a long history which makes for compatability 38
issues when creating and reading files. 39
40
This is further complicated by a large number of programs with variations on formats 41
One common issue is the handling of names longer than 100 characters. 42
GNU style long names are currently supported. 43
44
This is the ustar (Posix 1003.1) header. 45
46
struct header 47
{ 48
char t_name[100]; // 0 Filename 49
char t_mode[8]; // 100 Permissions 50
char t_uid[8]; // 108 Numerical User ID 51
char t_gid[8]; // 116 Numerical Group ID 52
char t_size[12]; // 124 Filesize 53
char t_mtime[12]; // 136 st_mtime 54
char t_chksum[8]; // 148 Checksum 55
char t_typeflag; // 156 Type of File 56
char t_linkname[100]; // 157 Target of Links 57
char t_magic[6]; // 257 "ustar" or other... 58
char t_version[2]; // 263 Version fixed to 00 59
char t_uname[32]; // 265 User Name 60
char t_gname[32]; // 297 Group Name 61
char t_devmajor[8]; // 329 Major for devices 62
char t_devminor[8]; // 337 Minor for devices 63
char t_prefix[155]; // 345 Prefix for t_name 64
char t_mfill[12]; // 500 Filler up to 512 65
}; 66
67
*/ 68
69
using System; 70
using System.Text; 71
72
namespace ICSharpCode.SharpZipLib.Tar 73
{ 74
75
76
/// <summary> 77
/// This class encapsulates the Tar Entry Header used in Tar Archives. 78
/// The class also holds a number of tar constants, used mostly in headers. 79
/// </summary> 80
public class TarHeader : ICloneable 81
{ 82
/// <summary> 83
/// The length of the name field in a header buffer. 84
/// </summary> 85
public readonly static int NAMELEN = 100; 86
87
/// <summary> 88
/// The length of the mode field in a header buffer. 89
/// </summary> 90
public readonly static int MODELEN = 8; 91
92
/// <summary> 93
/// The length of the user id field in a header buffer. 94
/// </summary> 95
public readonly static int UIDLEN = 8; 96
97
/// <summary> 98
/// The length of the group id field in a header buffer. 99
/// </summary> 100
public readonly static int GIDLEN = 8; 101
102
/// <summary> 103
/// The length of the checksum field in a header buffer. 104
/// </summary> 105
public readonly static int CHKSUMLEN = 8; 106
107
/// <summary> 108
/// Offset of checksum in a header buffer. 109
/// </summary> 110
public const int CHKSUMOFS = 148; 111
112
/// <summary> 113
/// The length of the size field in a header buffer. 114
/// </summary> 115
public readonly static int SIZELEN = 12; 116
117
/// <summary> 118
/// The length of the magic field in a header buffer. 119
/// </summary> 120
public readonly static int MAGICLEN = 6; 121
122
/// <summary> 123
/// The length of the version field in a header buffer. 124
/// </summary> 125
public readonly static int VERSIONLEN = 2; 126
127
/// <summary> 128
/// The length of the modification time field in a header buffer. 129
/// </summary> 130
public readonly static int MODTIMELEN = 12; 131
132
/// <summary> 133
/// The length of the user name field in a header buffer. 134
/// </summary> 135
public readonly static int UNAMELEN = 32; 136
137
/// <summary> 138
/// The length of the group name field in a header buffer. 139
/// </summary> 140
public readonly static int GNAMELEN = 32; 141
142
/// <summary> 143
/// The length of the devices field in a header buffer. 144
/// </summary> 145
public readonly static int DEVLEN = 8; 146
147
// 148
// LF_ constants represent the "type" of an entry 149
// 150
151
/// <summary> 152
/// The "old way" of indicating a normal file. 153
/// </summary> 154
public const byte LF_OLDNORM = 0; 155
156
/// <summary> 157
/// Normal file type. 158
/// </summary> 159
public const byte LF_NORMAL = (byte) '0'; 160
161
/// <summary> 162
/// Link file type. 163
/// </summary> 164
public const byte LF_LINK = (byte) '1'; 165
166
/// <summary> 167
/// Symbolic link file type. 168
/// </summary> 169
public const byte LF_SYMLINK = (byte) '2'; 170
171
/// <summary> 172
/// Character device file type. 173
/// </summary> 174
public const byte LF_CHR = (byte) '3'; 175
176
/// <summary> 177
/// Block device file type. 178
/// </summary> 179
public const byte LF_BLK = (byte) '4'; 180
181
/// <summary> 182
/// Directory file type. 183
/// </summary> 184
public const byte LF_DIR = (byte) '5'; 185
186
/// <summary> 187
/// FIFO (pipe) file type. 188
/// </summary> 189
public const byte LF_FIFO = (byte) '6'; 190
191
/// <summary> 192
/// Contiguous file type. 193
/// </summary> 194
public const byte LF_CONTIG = (byte) '7'; 195
196
/// <summary> 197
/// Posix.1 2001 global extended header 198
/// </summary> 199
public const byte LF_GHDR = (byte) 'g'; 200
201
/// <summary> 202
/// Posix.1 2001 extended header 203
/// </summary> 204
public readonly static byte LF_XHDR = (byte) 'x'; 205
206
207
208
209
// POSIX allows for upper case ascii type as extensions 210
211
/// <summary> 212
/// Solaris access control list file type 213
/// </summary> 214
public const byte LF_ACL = (byte) 'A'; 215
216
/// <summary> 217
/// GNU dir dump file type 218
/// This is a dir entry that contains the names of files that were in the 219
/// dir at the time the dump was made 220
/// </summary> 221
public const byte LF_GNU_DUMPDIR = (byte) 'D'; 222
223
/// <summary> 224
/// Solaris Extended Attribute File 225
/// </summary> 226
public const byte LF_EXTATTR = (byte) 'E' ; 227
228
/// <summary> 229
/// Inode (metadata only) no file content 230
/// </summary> 231
public const byte LF_META = (byte) 'I'; 232
233
/// <summary> 234
/// Identifies the next file on the tape as having a long link name 235
/// </summary> 236
public const byte LF_GNU_LONGLINK = (byte) 'K'; 237
238
/// <summary> 239
/// Identifies the next file on the tape as having a long name 240
/// </summary> 241
public const byte LF_GNU_LONGNAME = (byte) 'L'; 242
243
/// <summary> 244
/// Continuation of a file that began on another volume 245
/// </summary> 246
public const byte LF_GNU_MULTIVOL = (byte) 'M'; 247
248
/// <summary> 249
/// For storing filenames that dont fit in the main header (old GNU) 250
/// </summary> 251
public const byte LF_GNU_NAMES = (byte) 'N'; 252
253
/// <summary> 254
/// GNU Sparse file 255
/// </summary> 256
public const byte LF_GNU_SPARSE = (byte) 'S'; 257
258
/// <summary> 259
/// GNU Tape/volume header ignore on extraction 260
/// </summary> 261
public const byte LF_GNU_VOLHDR = (byte) 'V'; 262
263
/// <summary> 264
/// The magic tag representing a POSIX tar archive. (includes trailing NULL) 265
/// </summary> 266
public readonly static string TMAGIC = "ustar "; 267
268
/// <summary> 269
/// The magic tag representing an old GNU tar archive where version is included in magic and overwrites it 270
/// </summary> 271
public readonly static string GNU_TMAGIC = "ustar "; 272
273
274
string name; 275
276
/// <summary> 277
/// Get/set the name for this tar entry. 278
/// </summary> 279
/// <exception cref="ArgumentNullException">Thrown when attempting to set the property to null.</exception> 280
public string Name 281
{ 282




issues when creating and reading files.

