Skip to content

Commit

Permalink
Hacks needed to make embed_file work with -freestanding
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-randhawa-sifive committed Feb 2, 2024
1 parent 9a04a2c commit 16d89e2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions vlib/v/embed_file/embed_file.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module embed_file

import os
// import os

pub const is_used = 1

Expand Down Expand Up @@ -70,19 +70,19 @@ pub fn (mut ed EmbedFileData) data() &u8 {
unsafe {
ed.uncompressed = &u8(memdup(decompressed.data, ed.len))
}
} else {
mut path := os.resource_abs_path(ed.path)
if !os.is_file(path) {
path = ed.apath
if !os.is_file(path) {
panic('EmbedFileData error: files "${ed.path}" and "${ed.apath}" do not exist')
}
}
bytes := os.read_bytes(path) or {
panic('EmbedFileData error: "${path}" could not be read: ${err}')
}
ed.uncompressed = bytes.data
ed.free_uncompressed = true
// } else {
// mut path := os.resource_abs_path(ed.path)
// if !os.is_file(path) {
// path = ed.apath
// if !os.is_file(path) {
// panic('EmbedFileData error: files "${ed.path}" and "${ed.apath}" do not exist')
// }
// }
// bytes := os.read_bytes(path) or {
// panic('EmbedFileData error: "${path}" could not be read: ${err}')
// }
// ed.uncompressed = bytes.data
// ed.free_uncompressed = true
}
return ed.uncompressed
}
Expand Down

0 comments on commit 16d89e2

Please sign in to comment.