fast_ntfs/lib.rs
1// Copyright 2021-2026 Colin Finck <colin@reactos.org>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3//
4//! A low-level NTFS filesystem library implemented in Rust.
5//!
6//! [NTFS](https://en.wikipedia.org/wiki/NTFS) is the primary filesystem in all versions of Windows (since Windows NT 3.1 in 1993).
7//! This crate is geared towards the NTFS 3.x versions used in Windows 2000 up to the current Windows 11.
8//! However, the basics are expected to be compatible to even earlier versions.
9//!
10//! The crate is `no_std`-compatible and therefore usable from firmware level code up to user-mode applications.
11//!
12//! # Getting started
13//! 1. Create an [`Ntfs`] structure from a reader by calling [`Ntfs::new`].
14//! 2. Retrieve the [`NtfsFile`] of the root directory via [`Ntfs::root_directory`].
15//! 3. Dig into its attributes via [`NtfsFile::attributes`], go even deeper via [`NtfsFile::attributes_raw`] or use one of the convenience functions, like [`NtfsFile::directory_index`], [`NtfsFile::info`] or [`NtfsFile::name`].
16//!
17//! # Example
18//! The following example dumps the names of all files and folders in the root directory of a given NTFS filesystem.
19//! The list is directly taken from the NTFS index, hence it's sorted in ascending order with respect to NTFS's understanding of case-insensitive string comparison.
20//!
21//! ```no_run
22//! # use fast_ntfs::Ntfs;
23//! # let mut fs = std::io::Cursor::new(vec![]);
24//! let ntfs = Ntfs::new(&mut fs).unwrap();
25//! let root_dir = ntfs.root_directory(&mut fs).unwrap();
26//! let index = root_dir.directory_index(&mut fs).unwrap();
27//! let mut iter = index.entries();
28//!
29//! while let Some(entry) = iter.next(&mut fs) {
30//! let entry = entry.unwrap();
31//! let file_name = entry.key().unwrap().unwrap();
32//! println!("{}", file_name.name());
33//! }
34//! ```
35//!
36//! Check out the [docs](https://docs.rs/fast_ntfs), the tests, and the supplied [`ntfs-shell`](https://github.com/gembleman/ntfs/tree/master/examples/ntfs-shell) application for more examples on how to use the `fast_ntfs` library.
37
38#![cfg_attr(not(feature = "std"), no_std)]
39#![cfg_attr(docsrs, feature(doc_cfg))]
40#![doc(html_logo_url = "https://colinfinck.de/img/software/ntfs.svg")]
41#![forbid(unsafe_code)]
42
43extern crate alloc;
44
45#[macro_use]
46mod helpers;
47
48mod attribute;
49pub mod attribute_value;
50mod boot_sector;
51mod error;
52mod file;
53mod file_reference;
54mod guid;
55mod index;
56mod index_entry;
57mod index_record;
58pub mod indexes;
59pub mod io;
60mod mapped_data_runs;
61mod ntfs;
62mod record;
63pub mod structured_values;
64mod time;
65mod traits;
66pub mod types;
67mod upcase_table;
68
69pub use crate::attribute::*;
70pub use crate::error::*;
71pub use crate::file::*;
72pub use crate::file_reference::*;
73pub use crate::guid::*;
74pub use crate::index::*;
75pub use crate::index_entry::*;
76pub use crate::index_record::*;
77pub use crate::ntfs::*;
78pub use crate::time::*;
79pub use crate::traits::*;
80pub use crate::upcase_table::*;