You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-5
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,7 @@ After UTF-8 encoding, `metadataPath` must be at most `0xffff` bytes in length.
65
65
compress:true,
66
66
compressionLevel:6,
67
67
forceZip64Format:false,
68
+
forceDosTimestamp:false,
68
69
fileComment:"", // or a UTF-8 Buffer
69
70
}
70
71
```
@@ -86,6 +87,14 @@ If `forceZip64Format` is `true`, yazl will use ZIP64 format in this entry's Data
86
87
and Central Directory Record even if not needed (this may be useful for testing.).
87
88
Otherwise, yazl will use ZIP64 format where necessary.
88
89
90
+
Since yazl version 3.3.0, yazl includes the Info-ZIP "universal timestamp" extended field (`0x5455` aka `"UT"`) to encode the `mtime`.
91
+
The Info-ZIP timestamp is a more modern encoding for the mtime and is generally recommended.
92
+
Set `forceDosTimestamp` to `true` to revert to the pre-3.3.0 behvior, disabling this extended field.
93
+
The DOS encoding is always included regardless of this option, because it is required in the fixed-size metadata of every archive entry.
94
+
The benefits of the Info-ZIP encoding include: timezone is specified as always UTC, which is better for cloud environments and any teams working in multiple timezones; capable of encoding "time 0", the unix epoch in 1970, which is better for some package managers; the precision is 1-second accurate rather than rounded to the nearest even second. The disadvantages of including this field are: it requires an extra 9 bytes of metadata per entry added to the archive.
95
+
96
+
When attempting to encode an `mtime` outside the supported range for either format, such as the year 1970 in the DOS format or the year 2039 for the modern format, the time will clamped to the closest supported time.
97
+
89
98
If `fileComment` is a `string`, it will be encoded with UTF-8.
90
99
If `fileComment` is a `Buffer`, it should be a UTF-8 encoded string.
91
100
In UTF-8, `fileComment` must be at most `0xffff` bytes in length.
@@ -126,12 +135,13 @@ See `addFile()` for the meaning of the `metadataPath` parameter.
126
135
compress:true,
127
136
compressionLevel:6,
128
137
forceZip64Format:false,
138
+
forceDosTimestamp:false,
129
139
fileComment:"", // or a UTF-8 Buffer
130
140
size:12345, // example value
131
141
}
132
142
```
133
143
134
-
See `addFile()` for the meaning of `mtime`, `mode`, `compress`, `compressionLevel`, `forceZip64Format`, and `fileComment`.
144
+
See `addFile()` for the meaning of `mtime`, `mode`, `compress`, `compressionLevel`, `forceZip64Format`, `forceDosTimestamp`, and `fileComment`.
135
145
If `size` is given, it will be checked against the actual number of bytes in the `readStream`,
136
146
and an error will be emitted if there is a mismatch.
137
147
See the documentation on `calculatedTotalSizeCallback` for why the `size` option exists.
@@ -162,11 +172,12 @@ See `addFile()` for info about the `metadataPath` parameter.
162
172
compress:true,
163
173
compressionLevel:6,
164
174
forceZip64Format:false,
175
+
forceDosTimestamp:false,
165
176
fileComment:"", // or a UTF-8 Buffer
166
177
}
167
178
```
168
179
169
-
See `addFile()` for the meaning of `mtime`, `mode`, `compress`, `compressionLevel`, `forceZip64Format`, and `fileComment`.
180
+
See `addFile()` for the meaning of `mtime`, `mode`, `compress`, `compressionLevel`, `forceZip64Format`, `forceDosTimestamp`, and `fileComment`.
170
181
171
182
This method has the unique property that General Purpose Bit `3` will not be used in the Local File Header.
172
183
This doesn't matter for unzip implementations that conform to the Zip File Spec.
@@ -210,10 +221,11 @@ If `metadataPath` does not end with a `"/"`, a `"/"` will be appended.
210
221
{
211
222
mtime:newDate(),
212
223
mode:040775,
224
+
forceDosTimestamp:false,
213
225
}
214
226
```
215
227
216
-
See `addFile()` for the meaning of `mtime`and `mode`.
228
+
See `addFile()` for the meaning of `mtime`, `mode`, and `forceDosTimestamp`.
// Here is one specification for this: https://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.html
593
+
// See also the Info-ZIP source code unix/unix.c:set_extra_field() and zipfile.c:ef_scan_ut_time().
0 commit comments