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: s2/README.md
+89-20
Original file line number
Diff line number
Diff line change
@@ -112,12 +112,20 @@ For big skips the decompressor is able to skip blocks without decompressing them
112
112
## Single Blocks
113
113
114
114
Similar to Snappy S2 offers single block compression.
115
-
Blocks do not offer the same flexibility and safety as streams, but may be preferable for very small payloads, less than 100K.
115
+
Blocks do not offer the same flexibility and safety as streams,
116
+
but may be preferable for very small payloads, less than 100K.
116
117
117
-
Using a simple `dst := s2.Encode(nil, src)` will compress `src` and return the compressed result. It is possible to provide a destination buffer. If the buffer has a capacity of `s2.MaxEncodedLen(len(src))` it will be used. If not a new will be allocated. Alternatively `EncodeBetter` can also be used for better, but slightly slower compression.
118
+
Using a simple `dst := s2.Encode(nil, src)` will compress `src` and return the compressed result.
119
+
It is possible to provide a destination buffer.
120
+
If the buffer has a capacity of `s2.MaxEncodedLen(len(src))` it will be used.
121
+
If not a new will be allocated.
118
122
119
-
Similarly to decompress a block you can use `dst, err := s2.Decode(nil, src)`. Again an optional destination buffer can be supplied.
120
-
The `s2.DecodedLen(src)` can be used to get the minimum capacity needed. If that is not satisfied a new buffer will be allocated.
123
+
Alternatively `EncodeBetter`/`EncodeBest` can also be used for better, but slightly slower compression.
124
+
125
+
Similarly to decompress a block you can use `dst, err := s2.Decode(nil, src)`.
126
+
Again an optional destination buffer can be supplied.
127
+
The `s2.DecodedLen(src)` can be used to get the minimum capacity needed.
128
+
If that is not satisfied a new buffer will be allocated.
121
129
122
130
Block function always operate on a single goroutine since it should only be used for small payloads.
123
131
@@ -151,23 +159,28 @@ Directories can be wildcards as well. testdir/*/*.txt will match testdir/subdir/
151
159
152
160
Options:
153
161
-bench int
154
-
Run benchmark n times. No output will be written
162
+
Run benchmark n times. No output will be written
155
163
-blocksize string
156
-
Max block size. Examples: 64K, 256K, 1M, 4M. Must be power of two and <= 4MB (default "4M")
157
-
-cWrite all output to stdout. Multiple input files will be concatenated
164
+
Max block size. Examples: 64K, 256K, 1M, 4M. Must be power of two and <= 4MB (default "4M")
165
+
-cWrite all output to stdout. Multiple input files will be concatenated
158
166
-cpu int
159
-
Compress using this amount of threads (default CPU_THREADS])
167
+
Compress using this amount of threads (default 32)
160
168
-faster
161
-
Compress faster, but with a minor compression loss
169
+
Compress faster, but with a minor compression loss
162
170
-help
163
-
Display help
171
+
Display help
164
172
-pad string
165
-
Pad size to a multiple of this value, Examples: 500, 64K, 256K, 1M, 4M, etc (default "1")
166
-
-qDon't write any output to terminal, except errors
173
+
Pad size to a multiple of this value, Examples: 500, 64K, 256K, 1M, 4M, etc (default "1")
174
+
-qDon't write any output to terminal, except errors
167
175
-rm
168
-
Delete source file(s) after successful compression
176
+
Delete source file(s) after successful compression
169
177
-safe
170
-
Do not overwrite output files
178
+
Do not overwrite output files
179
+
-slower
180
+
Compress more, but a lot slower
181
+
-verify
182
+
Verify written files
183
+
171
184
```
172
185
173
186
## s2d
@@ -184,17 +197,73 @@ Directories can be wildcards as well. testdir/*/*.txt will match testdir/subdir/
184
197
185
198
Options:
186
199
-bench int
187
-
Run benchmark n times. No output will be written
188
-
-cWrite all output to stdout. Multiple input files will be concatenated
200
+
Run benchmark n times. No output will be written
201
+
-cWrite all output to stdout. Multiple input files will be concatenated
189
202
-help
190
-
Display help
191
-
-qDon't write any output to terminal, except errors
203
+
Display help
204
+
-qDon't write any output to terminal, except errors
192
205
-rm
193
-
Delete source file(s) after successful decompression
206
+
Delete source file(s) after successful decompression
194
207
-safe
195
-
Do not overwrite output files
208
+
Do not overwrite output files
209
+
-verify
210
+
Verify files, but do not write output
211
+
```
212
+
213
+
## s2sx: self-extracting archives
214
+
215
+
s2sx allows creating self-extracting archives with no dependencies.
216
+
217
+
By default, executables are created for the same platforms as the host os,
218
+
but this can be overridden with `-os` parameter.
219
+
220
+
Extracted files have 0666 permissions, except when untar option used.
196
221
197
222
```
223
+
Usage: s2sx [options] file1 file2
224
+
225
+
Compresses all files supplied as input separately.
226
+
If files have '.s2' extension they are assumed to be compressed already.
227
+
Output files are written as 'filename.s2sfx' and with '.exe' for windows targets.
228
+
By default output files will be overwritten.
229
+
230
+
Wildcards are accepted: testdir/*.txt will compress all files in testdir ending with .txt
231
+
Directories can be wildcards as well. testdir/*/*.txt will match testdir/subdir/b.txt
232
+
233
+
Options:
234
+
-arch string
235
+
Destination architecture (default "amd64")
236
+
-c Write all output to stdout. Multiple input files will be concatenated
237
+
-cpu int
238
+
Compress using this amount of threads (default 32)
239
+
-help
240
+
Display help
241
+
-os string
242
+
Destination operating system (default "windows")
243
+
-q Don't write any output to terminal, except errors
244
+
-rm
245
+
Delete source file(s) after successful compression
246
+
-safe
247
+
Do not overwrite output files
248
+
-untar
249
+
Untar on destination
250
+
251
+
Available platforms are:
252
+
253
+
* darwin-amd64
254
+
* linux-amd64
255
+
* windows-amd64
256
+
```
257
+
258
+
### Self-extracting TAR files
259
+
260
+
If you wrap a TAR file you can specify `-untar` to make it untar on the destination host.
261
+
262
+
Files are extracted to the current folder with the path specified in the tar file.
263
+
264
+
Note that tar files are not validated before they are wrapped.
265
+
266
+
For security reasons files that move below the root folder are not allowed.
0 commit comments