v2 / vlib / v / embed_file / embed_file_notd_freestanding.v
18 lines · 16 sloc · 452 bytes · 96e4a09b66d07a9f4f5e9a4885bdbc5cec4b0d75
Raw
1module embed_file
2
3import os
4
5fn reload_from_file_at_runtime(mut ed EmbedFileData) {
6 mut path := os.resource_abs_path(ed.path)
7 if !os.is_file(path) {
8 path = ed.apath
9 if !os.is_file(path) {
10 panic('EmbedFileData error: files "${ed.path}" and "${ed.apath}" do not exist')
11 }
12 }
13 bytes := os.read_bytes(path) or {
14 panic('EmbedFileData error: "${path}" could not be read: ${err}')
15 }
16 ed.uncompressed = bytes.data
17 ed.free_uncompressed = true
18}
19