compio_fs/
lib.rs

1//! Filesystem utilities.
2
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![warn(missing_docs)]
5#![deny(rustdoc::broken_intra_doc_links)]
6#![doc(
7    html_logo_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
8)]
9#![doc(
10    html_favicon_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
11)]
12#![cfg_attr(feature = "read_buf", feature(read_buf, core_io_borrowed_buf))]
13#![cfg_attr(
14    all(windows, feature = "windows_by_handle"),
15    feature(windows_by_handle)
16)]
17
18mod file;
19pub use file::*;
20
21mod open_options;
22pub use open_options::*;
23
24mod metadata;
25pub use metadata::*;
26
27mod stdio;
28pub use stdio::*;
29
30mod utils;
31pub use utils::*;
32
33mod async_fd;
34pub use async_fd::*;
35
36#[cfg(windows)]
37pub mod named_pipe;
38
39#[cfg(unix)]
40pub mod pipe;
41
42#[cfg(unix)]
43pub(crate) fn path_string(path: impl AsRef<std::path::Path>) -> std::io::Result<std::ffi::CString> {
44    use std::os::unix::ffi::OsStrExt;
45
46    std::ffi::CString::new(path.as_ref().as_os_str().as_bytes().to_vec()).map_err(|_| {
47        std::io::Error::new(
48            std::io::ErrorKind::InvalidInput,
49            "file name contained an unexpected NUL byte",
50        )
51    })
52}