(path_ptr: *const u8)
| 2379 | |
| 2380 | #[no_mangle] |
| 2381 | pub extern "C" fn bloom_read_file(path_ptr: *const u8) -> *const u8 { |
| 2382 | let path = str_from_header(path_ptr); |
| 2383 | // Always return a valid Perry string. A null pointer would NaN-box into a |
| 2384 | // string-typed JS value pointing at address 0; `.length` / `.charCodeAt` |
| 2385 | // would then segfault. Callers detect "missing file" via `data.length === 0`. |
| 2386 | match std::fs::read_to_string(path) { |
| 2387 | Ok(contents) => alloc_perry_string(&contents), |
| 2388 | Err(_) => alloc_perry_string(""), |
| 2389 | } |
| 2390 | } |
| 2391 | |
| 2392 | // ============================================================ |
| 2393 | // Input injection + platform detection |
nothing calls this directly
no test coverage detected