summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/cachedir.rs25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/bin/cachedir.rs b/src/bin/cachedir.rs
index 4d35ae8..0675248 100644
--- a/src/bin/cachedir.rs
+++ b/src/bin/cachedir.rs
@@ -12,17 +12,12 @@
//! $
//! ~~~
+use cachedir::{is_cachedir_tag, CACHEDIR_TAG, TAG};
use clap::{Parser, Subcommand};
-use std::fs::{read, remove_file, write};
-use std::path::{Path, PathBuf};
+use std::fs::{remove_file, write};
+use std::path::PathBuf;
use walkdir::{DirEntry, WalkDir};
-/// Name of tag file.
-const CACHEDIR_TAG: &str = "CACHEDIR.TAG";
-
-/// Prefix of contents of tag file.
-const TAG: &str = "Signature: 8a477f597d28d172789f06886806bc55";
-
/// The main program.
fn main() {
if let Err(e) = real_main() {
@@ -115,20 +110,6 @@ where
Ok(())
}
-/// Is the given file a cache directory tag?
-fn is_cachedir_tag(filename: &Path) -> Result<bool, std::io::Error> {
- if filename.exists() {
- let data = read(filename)?;
- if data.len() >= TAG.len() {
- Ok(&data[..TAG.len()] == TAG.as_bytes())
- } else {
- Ok(false)
- }
- } else {
- Ok(false)
- }
-}
-
/// Return path to tag file in a directory.
fn tag_filename(entry: &DirEntry) -> PathBuf {
entry.path().join(CACHEDIR_TAG)