MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_read_file

Function bloom_read_file

native/windows/src/lib.rs:1593–1604  ·  view source on GitHub ↗
(path_ptr: *const u8)

Source from the content-addressed store, hash-verified

1591
1592#[no_mangle]
1593pub extern "C" fn bloom_read_file(path_ptr: *const u8) -> *const u8 {
1594 let path = str_from_header(path_ptr);
1595 // Always return a valid Perry string. A null pointer would NaN-box into a
1596 // string-typed JS value pointing at address 0; subsequent `.length` /
1597 // `.charCodeAt` reads dereference the bogus StringHeader and segfault.
1598 // Callers detect "missing file" via `data.length === 0` (e.g. the
1599 // jump game's discoverLevels probe across level1..level10 / custom_*).
1600 match std::fs::read_to_string(path) {
1601 Ok(contents) => alloc_perry_string(&contents),
1602 Err(_) => alloc_perry_string(""),
1603 }
1604}
1605
1606#[no_mangle]
1607pub extern "C" fn bloom_get_touch_x(index: f64) -> f64 { engine().input.get_touch_x(index as usize) }

Callers

nothing calls this directly

Calls 2

str_from_headerFunction · 0.85
alloc_perry_stringFunction · 0.50

Tested by

no test coverage detected