fts-sys-0.2.7/.cargo_vcs_info.json0000644000000001360000000000100124520ustar { "git": { "sha1": "341a8149f9e20ec08b61e5fb428d3ec1b594ed29" }, "path_in_vcs": "" }fts-sys-0.2.7/.gitignore000064400000000000000000000000701046102023000132270ustar 00000000000000/target Cargo.lock *.code-workspace .directory *.tar.gz fts-sys-0.2.7/CHANGELOG.md000064400000000000000000000015251046102023000130560ustar 00000000000000# Change log This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.2.7] - 2023-10-31 ### Changed - Updated dependencies: `bindgen`. ## [0.2.6] - 2023-06-07 ### Changed - Updated build script to better integrate with `cargo`. ## [0.2.5] - 2023-04-18 ### Changed - Updated dependencies: `bindgen`. ## [0.2.4] - 2022-11-22 ### Changed - Updated dependencies: `bindgen`. ## [0.2.3] - 2022-11-20 ### Changed - Updated dependencies: `bindgen`. ## [0.2.2] - 2022-09-03 ### Changed - Updated Rust edition to 2021. - Updated dependencies: `bindgen`. ## [0.2.1] - 2021-07-28 ### Changed - Updated dependencies: `bindgen`. ## [0.2.0] - 2021-04-17 ### Changed - Building for non-UNIX platforms is now supported, but it results in an empty crate. ## [0.1.0] - 2021-03-06 ### Added - Initial release. fts-sys-0.2.7/Cargo.toml0000644000000020200000000000100104420ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "fts-sys" version = "0.2.7" authors = ["Koutheir Attouchi "] build = "build.rs" links = "c" description = "File hierarchy traversal functions (FTS)" documentation = "https://docs.rs/fts-sys" readme = "README.md" keywords = [ "fts", "filesystem", "tree", "hierarchy", ] categories = [ "external-ffi-bindings", "filesystem", ] license = "MIT" repository = "https://github.com/koutheir/fts-sys" [build-dependencies.bindgen] version = "0.68" [target."cfg(unix)".dependencies.libc] version = "0.2" fts-sys-0.2.7/Cargo.toml.orig000064400000000000000000000012261046102023000141320ustar 00000000000000[package] name = "fts-sys" description = "File hierarchy traversal functions (FTS)" version = "0.2.7" # Remember to update `html_root_url`. authors = ["Koutheir Attouchi "] edition = "2021" readme = "README.md" license = "MIT" keywords = ["fts", "filesystem", "tree", "hierarchy"] categories = ["external-ffi-bindings", "filesystem"] build = "build.rs" links = "c" repository = "https://github.com/koutheir/fts-sys" documentation = "https://docs.rs/fts-sys" [target.'cfg(unix)'.dependencies] libc = { version = "0.2" } [build-dependencies] bindgen = { version = "0.68" } fts-sys-0.2.7/LICENSE.txt000064400000000000000000000021151046102023000130640ustar 00000000000000MIT License Copyright (c) 2021-2023 Koutheir Attouchi. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fts-sys-0.2.7/README.md000064400000000000000000000011631046102023000125220ustar 00000000000000[![crates.io](https://img.shields.io/crates/v/fts-sys.svg)](https://crates.io/crates/fts-sys) [![docs.rs](https://docs.rs/fts-sys/badge.svg)](https://docs.rs/fts-sys) [![license](https://img.shields.io/github/license/koutheir/fts-sys?color=black)](https://raw.githubusercontent.com/koutheir/fts-sys/master/LICENSE.md) # `fts-sys`: Unsafe Rust bindings for FTS functions provided by `libc` The FTS functions enable traversing file hierarchies. ## Versioning This project adheres to [Semantic Versioning]. The `CHANGELOG.md` file details notable changes over time. [Semantic Versioning]: https://semver.org/spec/v2.0.0.html fts-sys-0.2.7/build.rs000064400000000000000000000050071046102023000127110ustar 00000000000000use std::env; use std::path::{Path, PathBuf}; fn main() { let out_dir = env::var_os("OUT_DIR") .map(PathBuf::from) .expect("fts-sys: Environment variable 'OUT_DIR' was not defined."); println!("cargo:root={}", out_dir.to_str().unwrap()); if !target_os_is_supported() { return; } generate_bindings(&out_dir) } fn target_os_is_supported() -> bool { match get_target_os().as_deref() { None => false, // Do not build anything for bare metal architectures. Some("linux") | Some("android") | Some("androideabi") | Some("dragonfly") | Some("freebsd") | Some("netbsd") | Some("openbsd") => { true // Continue, probably supported. } _ => false, // Do not build anything, probably unsupported. } } fn get_target_os() -> Option { let target = env::var("TARGET").expect("selinux-sys: Environment variable 'TARGET' was not defined."); let components: Vec<_> = target.split('-').collect(); let os_index = match components.len() { 2 => { // e.g., aarch64-fuchsia, wasm32-wasi, x86_64-fuchsia if components[1] == "none" { return None; // Bare metal target. } 1 } 3 | 4 => { // e.g., aarch64-unknown-freebsd, aarch64-unknown-linux-gnu if components[1] == "none" || components[2] == "none" { return None; // Bare metal target. } 2 } _ => panic!("Unrecognized target triplet '{target}'"), }; Some(String::from(components[os_index])) } fn generate_bindings(out_dir: &Path) { let bindings = bindgen::Builder::default() .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .default_enum_style(bindgen::EnumVariation::ModuleConsts) .default_macro_constant_type(bindgen::MacroTypeVariation::Signed) .size_t_is_usize(true) .derive_debug(true) .derive_copy(true) .impl_debug(true) .allowlist_function("fts_(open|read|children|set|close)") .allowlist_type("FTSENT") .blocklist_type("__.+") .blocklist_type("(FTS|stat|timespec|dev_t|ino_t|nlink_t)") .allowlist_var("FTS_.+") //.clang_arg("-D_FILE_OFFSET_BITS=64") .header("src/fts-sys.h") .generate() .expect("fts-sys: Failed to generate Rust bindings for 'fts.h'."); bindings .write_to_file(out_dir.join("fts-sys.rs")) .expect("fts-sys: Failed to write 'fts-sys.rs'.") } fts-sys-0.2.7/src/fts-sys.h000064400000000000000000000000761046102023000136150ustar 00000000000000#include #include #include fts-sys-0.2.7/src/lib.rs000064400000000000000000000007461046102023000131540ustar 00000000000000#![doc = include_str!("../README.md")] #![cfg(unix)] #![doc(html_root_url = "https://docs.rs/fts-sys/0.2.7")] #![warn(unsafe_op_in_unsafe_fn)] #![allow( non_upper_case_globals, non_camel_case_types, non_snake_case, clippy::redundant_static_lifetimes )] use libc::dev_t; use libc::ino_t; use libc::nlink_t; use libc::stat; #[repr(C)] #[derive(Debug)] pub struct FTS { _unused: [u8; 0], } include!(concat!(env!("OUT_DIR"), "/fts-sys.rs")); #[cfg(test)] mod tests; fts-sys-0.2.7/src/tests.rs000064400000000000000000000014611046102023000135430ustar 00000000000000#![cfg(all(test, unix))] use std::os::raw::c_char; use std::ptr; #[test] fn fts_open() { let paths: [*const c_char; 2] = ["/\0".as_ptr().cast(), ptr::null()]; let fts = unsafe { super::fts_open(paths.as_ptr().cast(), super::FTS_PHYSICAL, None) }; assert_ne!(fts, ptr::null_mut()); unsafe { super::fts_close(fts) }; } #[test] fn fts_read() { let paths: [*const c_char; 2] = ["/\0".as_ptr().cast(), ptr::null()]; let fts = unsafe { super::fts_open(paths.as_ptr().cast(), super::FTS_PHYSICAL, None) }; assert_ne!(fts, ptr::null_mut()); let entry = unsafe { super::fts_read(fts) }; assert_ne!(entry, ptr::null_mut()); if let Some(entry) = unsafe { entry.as_ref() } { assert_ne!(entry.fts_name.as_ptr(), ptr::null_mut()); } unsafe { super::fts_close(fts) }; }