1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-FileCopyrightText: 2024 Shun Sakai
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! The `hf` crate is a cross-platform library for manipulating hidden files or
//! hidden directories.
//!
//! # Examples
//!
//! ## On Unix
//!
//! ```
//! # #[cfg(unix)]
//! # {
//! use std::fs::File;
//!
//! let temp_dir = tempfile::tempdir().unwrap();
//! let temp_dir = temp_dir.path();
//! let file_path = temp_dir.join("file");
//! let hidden_file_path = temp_dir.join(".file");
//!
//! File::create(&file_path).unwrap();
//! assert!(file_path.exists());
//! assert!(!hidden_file_path.exists());
//!
//! hf::hide(&file_path).unwrap();
//! assert!(!file_path.exists());
//! assert!(hidden_file_path.exists());
//!
//! hf::show(&hidden_file_path).unwrap();
//! assert!(file_path.exists());
//! assert!(!hidden_file_path.exists());
//! # }
//! ```
//!
//! ## On Windows
//!
//! ```
//! # #[cfg(windows)]
//! # {
//! use std::fs::File;
//!
//! let temp_dir = tempfile::tempdir().unwrap();
//! let file_path = temp_dir.path().join("file");
//!
//! File::create(&file_path).unwrap();
//! assert!(!hf::is_hidden(&file_path).unwrap());
//!
//! hf::hide(&file_path).unwrap();
//! assert!(hf::is_hidden(&file_path).unwrap());
//!
//! hf::show(&file_path).unwrap();
//! assert!(!hf::is_hidden(file_path).unwrap());
//! # }
//! ```

#![doc(html_root_url = "https://docs.rs/hf/0.3.0/")]
#![cfg_attr(doc_cfg, feature(doc_auto_cfg, doc_cfg))]
// Lint levels of rustc.
#![deny(missing_debug_implementations, missing_docs)]
#![warn(rust_2018_idioms)]
// Lint levels of Clippy.
#![warn(clippy::cargo, clippy::nursery, clippy::pedantic)]
#![allow(clippy::multiple_crate_versions)]

mod ops;
mod platform;

pub use crate::ops::{hide, is_hidden, show};