Skip to main content

ntfs/
lib.rs

1// Copyright 2021 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//! ```ignore
22//! let mut ntfs = Ntfs::new(&mut fs).unwrap();
23//! let root_dir = ntfs.root_directory(&mut fs).unwrap();
24//! let index = root_dir.directory_index(&mut fs).unwrap();
25//! let mut iter = index.entries();
26//!
27//! while let Some(entry) = iter.next(&mut fs) {
28//!     let entry = entry.unwrap();
29//!     let file_name = entry.key().unwrap();
30//!     println!("{}", file_name.name());
31//! }
32//! ```
33//!
34//! Check out the [docs](https://docs.rs/ntfs), the tests, and the supplied [`ntfs-shell`](https://github.com/ColinFinck/ntfs/tree/master/examples/ntfs-shell) application for more examples on how to use the `ntfs` library.
35
36#![cfg_attr(not(feature = "std"), no_std)]
37#![cfg_attr(docsrs, feature(doc_cfg))]
38#![forbid(unsafe_code)]
39
40extern crate alloc;
41
42#[macro_use]
43mod helpers;
44
45mod attribute;
46pub mod attribute_value;
47mod boot_sector;
48mod error;
49mod file;
50mod file_reference;
51mod guid;
52mod index;
53mod index_entry;
54mod index_record;
55pub mod indexes;
56mod ntfs;
57mod record;
58pub mod structured_values;
59mod time;
60mod traits;
61pub mod types;
62mod upcase_table;
63
64pub use crate::attribute::*;
65pub use crate::error::*;
66pub use crate::file::*;
67pub use crate::file_reference::*;
68pub use crate::guid::*;
69pub use crate::index::*;
70pub use crate::index_entry::*;
71pub use crate::index_record::*;
72pub use crate::ntfs::*;
73pub use crate::time::*;
74pub use crate::traits::*;
75pub use crate::upcase_table::*;