polars_utils/
file.rs

1pub fn close_file(file: std::fs::File) -> std::io::Result<()> {
2    #[cfg(unix)]
3    {
4        use std::os::fd::IntoRawFd;
5        let fd = file.into_raw_fd();
6
7        if unsafe { libc::close(fd) } != 0 {
8            return Err(std::io::Error::last_os_error());
9        }
10    }
11
12    Ok(())
13}