(path_ptr: *const u8)
| 1591 | |
| 1592 | #[no_mangle] |
| 1593 | pub 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] |
| 1607 | pub extern "C" fn bloom_get_touch_x(index: f64) -> f64 { engine().input.get_touch_x(index as usize) } |
nothing calls this directly
no test coverage detected