pub fn c_path(
operation: &'static str,
path: &Path,
) -> Result<CString, PrimitiveError>Expand description
What:
A path as the NUL-terminated C string the system calls take.
Why:
A path with an interior NUL byte can name no file, so it fails with EINVAL before any call, instead of
reaching a system call with a truncated name.
In TS you’d write (pseudocode):
function cPath(operation: string, path: string): Buffer { if (path.includes('\0')) throw new PrimitiveError(operation, path, EINVAL); return Buffer.from(path + '\0'); }