| 1 | module embed_file |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | fn 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 |