deno.land / std@0.224.0 / archive / _common.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { PartialReadError } from "../io/buf_reader.ts";import type { Reader } from "../io/types.ts";
/** Base interface for {@linkcode TarMeta} */export interface TarInfo { /** * The underlying raw `st_mode` bits that contain the standard Unix * permissions for this file/directory. */ fileMode?: number; /** * Data modification time of the file at the time it was archived. It * represents the integer number of seconds since January 1, 1970, 00:00 UTC. */ mtime?: number; /** * Numeric user ID of the file owner. This is ignored if the operating system * does not support numeric user IDs. */ uid?: number; /** * Numeric group ID of the file owner. This is ignored if the operating * system does not support numeric group IDs. */ gid?: number; /** The name of the file owner. */ owner?: string; /** The group that the file owner belongs to. */ group?: string; /** * The type of file archived. * * @see {@linkcode FileTypes} */ type?: string;}
/** Base interface for {@linkcode TarMetaWithLinkName}. */export interface TarMeta extends TarInfo { /** * The name of the file, with directory names (if any) preceding the file * name, separated by slashes. */ fileName: string; /** * The size of the file in bytes; for archive members that are symbolic or * hard links to another file, this field is specified as zero. */ fileSize?: number;}
/** The type of file archived. */export enum FileTypes { "file" = 0, "link" = 1, "symlink" = 2, "character-device" = 3, "block-device" = 4, "directory" = 5, "fifo" = 6, "contiguous-file" = 7,}
export const HEADER_LENGTH = 512;
/*struct posix_header { // byte offset char name[100]; // 0 char mode[8]; // 100 char uid[8]; // 108 char gid[8]; // 116 char size[12]; // 124 char mtime[12]; // 136 char chksum[8]; // 148 char typeflag; // 156 char linkname[100]; // 157 char magic[6]; // 257 char version[2]; // 263 char uname[32]; // 265 char gname[32]; // 297 char devmajor[8]; // 329 char devminor[8]; // 337 char prefix[155]; // 345 // 500};*/
export const USTAR_STRUCTURE = [ { field: "fileName", length: 100, }, { field: "fileMode", length: 8, }, { field: "uid", length: 8, }, { field: "gid", length: 8, }, { field: "fileSize", length: 12, }, { field: "mtime", length: 12, }, { field: "checksum", length: 8, }, { field: "type", length: 1, }, { field: "linkName", length: 100, }, { field: "ustar", length: 8, }, { field: "owner", length: 32, }, { field: "group", length: 32, }, { field: "majorNumber", length: 8, }, { field: "minorNumber", length: 8, }, { field: "fileNamePrefix", length: 155, }, { field: "padding", length: 12, },] as const;
/** * @internal */export type UstarFields = (typeof USTAR_STRUCTURE)[number]["field"];
export async function readBlock( reader: Reader, p: Uint8Array,): Promise<number | null> { let bytesRead = 0; while (bytesRead < p.length) { const rr = await reader.read(p.subarray(bytesRead)); if (rr === null) { if (bytesRead === 0) { return null; } else { throw new PartialReadError(); } } bytesRead += rr; } return bytesRead;}
std

Version Info

Tagged at
3 weeks ago