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
70
71
72
73
74
75
76
77
78
79
80
81
// 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
//! and directories].
//!
//! This crate supports both Unix and Windows. On Unix, hidden files and
//! directories are files and directories that starts with a dot character
//! (`.`). On Windows, hidden files and directories are files and directories
//! with the hidden file attribute.
//!
//! # 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("foo.txt");
//! let hidden_file_path = hf::unix::hidden_file_name(&file_path).unwrap();
//! assert_eq!(hidden_file_path, temp_dir.join(".foo.txt"));
//! assert!(!file_path.exists());
//! assert!(!hidden_file_path.exists());
//!
//! 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("foo.txt");
//! assert!(!file_path.exists());
//!
//! File::create(&file_path).unwrap();
//! assert!(file_path.exists());
//! assert_eq!(hf::is_hidden(&file_path).unwrap(), false);
//!
//! hf::hide(&file_path).unwrap();
//! assert!(file_path.exists());
//! assert_eq!(hf::is_hidden(&file_path).unwrap(), true);
//!
//! hf::show(&file_path).unwrap();
//! assert!(file_path.exists());
//! assert_eq!(hf::is_hidden(file_path).unwrap(), false);
//! # }
//! ```
//!
//! [hidden files and directories]: https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory
// Lint levels of rustc.
pub use crate;
pub use crateunix;