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

Function bloom_read_file

native/android/src/lib.rs:1354–1367  ·  view source on GitHub ↗
(path_ptr: *const u8)

Source from the content-addressed store, hash-verified

1352
1353#[no_mangle]
1354pub extern "C" fn bloom_read_file(path_ptr: *const u8) -> *const u8 {
1355 let path = str_from_header(path_ptr);
1356 // Always return a valid Perry string. A null pointer would NaN-box into a
1357 // string-typed value pointing at address 0; subsequent `.length` /
1358 // `.charCodeAt` reads dereference the bogus StringHeader and segfault.
1359 // Callers detect "missing file" via `data.length === 0` (e.g. the jump
1360 // game's discoverLevels probe across level1..level10 / custom_*).
1361 // Parity with native/linux — Android previously returned null on Err,
1362 // crashing discoverLevels at the first non-existent level file.
1363 match std::fs::read_to_string(resolve_path(path)) {
1364 Ok(contents) => alloc_perry_string(&contents),
1365 Err(_) => alloc_perry_string(""),
1366 }
1367}
1368
1369#[no_mangle]
1370pub extern "C" fn bloom_get_touch_x(index: f64) -> f64 { engine().input.get_touch_x(index as usize) }

Callers

nothing calls this directly

Calls 3

str_from_headerFunction · 0.85
resolve_pathFunction · 0.70
alloc_perry_stringFunction · 0.50

Tested by

no test coverage detected