Giter VIP home page Giter VIP logo

fts-rs's Introduction

fts-rs

Actions Status Crates.io Docs.rs codecov

A Rust library for high performance directory walking using libc fts.

Documentation

Usage

[dependencies]
fts = "0.3.0"

Example

Use WalkDir for directory walking:

use std::path::Path;
use fts::walkdir::{WalkDir, WalkDirConf};

let path = Path::new( "." );
for p in WalkDir::new( WalkDirConf::new( path ) ) {
    println!( "{:?}", p.unwrap() );
}

Call fts_* function directly:

use std::ffi::CString;
use fts::ffi::{fts_open, fts_read, fts_close, FTS_LOGICAL};

let path    = CString::new( "." ).unwrap();
let paths   = vec![path.as_ptr(), std::ptr::null()];
let fts     = unsafe { fts_open ( paths.as_ptr(), FTS_LOGICAL, None ) };
let _ftsent = unsafe { fts_read ( fts ) };
let _       = unsafe { fts_close( fts ) };

Benchmark

A cargo bench result is the following. fts_walkdir is this library, readdir is std::fs:read_dir, walkdir is walkdir::WalkDir. a suffix _metadata means using call DirEntry::metadata().

test fts_walkdir          ... bench: 315,114,126 ns/iter (+/- 8,478,709)
test fts_walkdir_metadata ... bench: 480,089,245 ns/iter (+/- 11,478,335)
test readdir              ... bench: 575,856,224 ns/iter (+/- 15,021,486)
test readdir_metadata     ... bench: 790,838,218 ns/iter (+/- 12,780,010)
test walkdir              ... bench: 688,884,058 ns/iter (+/- 8,023,838)
test walkdir_metadata     ... bench: 904,379,691 ns/iter (+/- 10,212,776)

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

fts-rs's People

Contributors

dalance avatar dependabot-preview[bot] avatar apps4uco avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.