1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: support $embed_file('embed.vv', .zlib) (#12654)

This commit is contained in:
Leo Developer
2021-12-04 18:43:19 +01:00
committed by GitHub
parent 0f50ac3260
commit ace63594bf
24 changed files with 411 additions and 72 deletions

44
cmd/tools/vcompress.v Normal file
View File

@@ -0,0 +1,44 @@
module main
import compress.zlib
import os
enum CompressionType {
zlib
}
fn main() {
if os.args.len != 5 {
eprintln('v compress <type> <in> <out>')
eprintln('supported types: zlib')
exit(1)
}
compression_type := match os.args[2] {
'zlib' {
CompressionType.zlib
}
else {
eprintln('unsupported type: ${os.args[1]}')
exit(1)
}
}
path := os.args[3]
content := os.read_bytes(path) or {
eprintln('unable to read "$path": $err')
exit(1)
}
compressed := match compression_type {
.zlib {
zlib.compress(content) or {
eprintln('compression error: $err')
exit(1)
}
}
}
out_path := os.args[4]
os.write_file_array(out_path, compressed) or {
eprintln('failed to write "$out_path": $err')
exit(1)
}
}