mirror of
https://github.com/sharkdp/fd
synced 2024-09-15 22:20:45 +00:00
Rename fshelper to filesystem
This commit is contained in:
parent
e0cba4b700
commit
b415d7234b
12
src/main.rs
12
src/main.rs
|
@ -4,9 +4,9 @@ mod error;
|
||||||
mod app;
|
mod app;
|
||||||
mod exec;
|
mod exec;
|
||||||
mod exit_codes;
|
mod exit_codes;
|
||||||
|
mod filesystem;
|
||||||
mod filetypes;
|
mod filetypes;
|
||||||
mod filter;
|
mod filter;
|
||||||
mod fshelper;
|
|
||||||
mod options;
|
mod options;
|
||||||
mod output;
|
mod output;
|
||||||
mod regex_helper;
|
mod regex_helper;
|
||||||
|
@ -40,7 +40,7 @@ fn main() {
|
||||||
// Set the current working directory of the process
|
// Set the current working directory of the process
|
||||||
if let Some(base_directory) = matches.value_of("base-directory") {
|
if let Some(base_directory) = matches.value_of("base-directory") {
|
||||||
let basedir = Path::new(base_directory);
|
let basedir = Path::new(base_directory);
|
||||||
if !fshelper::is_dir(basedir) {
|
if !filesystem::is_dir(basedir) {
|
||||||
print_error_and_exit!(
|
print_error_and_exit!(
|
||||||
"The '--base-directory' path ('{}') is not a directory.",
|
"The '--base-directory' path ('{}') is not a directory.",
|
||||||
basedir.to_string_lossy()
|
basedir.to_string_lossy()
|
||||||
|
@ -60,7 +60,7 @@ fn main() {
|
||||||
|
|
||||||
// Get the current working directory
|
// Get the current working directory
|
||||||
let current_dir = Path::new(".");
|
let current_dir = Path::new(".");
|
||||||
if !fshelper::is_dir(current_dir) {
|
if !filesystem::is_dir(current_dir) {
|
||||||
print_error_and_exit!("Could not get current directory.");
|
print_error_and_exit!("Could not get current directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ fn main() {
|
||||||
Some(paths) => paths
|
Some(paths) => paths
|
||||||
.map(|path| {
|
.map(|path| {
|
||||||
let path_buffer = PathBuf::from(path);
|
let path_buffer = PathBuf::from(path);
|
||||||
if !fshelper::is_dir(&path_buffer) {
|
if !filesystem::is_dir(&path_buffer) {
|
||||||
print_error_and_exit!(
|
print_error_and_exit!(
|
||||||
"'{}' is not a directory.",
|
"'{}' is not a directory.",
|
||||||
path_buffer.to_string_lossy()
|
path_buffer.to_string_lossy()
|
||||||
|
@ -90,7 +90,7 @@ fn main() {
|
||||||
.map(|path_buffer| {
|
.map(|path_buffer| {
|
||||||
path_buffer
|
path_buffer
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.and_then(|pb| fshelper::absolute_path(pb.as_path()))
|
.and_then(|pb| filesystem::absolute_path(pb.as_path()))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -99,7 +99,7 @@ fn main() {
|
||||||
// Detect if the user accidentally supplied a path instead of a search pattern
|
// Detect if the user accidentally supplied a path instead of a search pattern
|
||||||
if !matches.is_present("full-path")
|
if !matches.is_present("full-path")
|
||||||
&& pattern.contains(std::path::MAIN_SEPARATOR)
|
&& pattern.contains(std::path::MAIN_SEPARATOR)
|
||||||
&& fshelper::is_dir(Path::new(pattern))
|
&& filesystem::is_dir(Path::new(pattern))
|
||||||
{
|
{
|
||||||
print_error_and_exit!(
|
print_error_and_exit!(
|
||||||
"The search pattern '{pattern}' contains a path-separation character ('{sep}') \
|
"The search pattern '{pattern}' contains a path-separation character ('{sep}') \
|
||||||
|
|
12
src/walk.rs
12
src/walk.rs
|
@ -1,6 +1,6 @@
|
||||||
use crate::exec;
|
use crate::exec;
|
||||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||||
use crate::fshelper;
|
use crate::filesystem;
|
||||||
use crate::options::Options;
|
use crate::options::Options;
|
||||||
use crate::output;
|
use crate::output;
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ fn spawn_senders(
|
||||||
let entry_path = entry.path();
|
let entry_path = entry.path();
|
||||||
|
|
||||||
let search_str: Cow<OsStr> = if config.search_full_path {
|
let search_str: Cow<OsStr> = if config.search_full_path {
|
||||||
match fshelper::path_absolute_form(entry_path) {
|
match filesystem::path_absolute_form(entry_path) {
|
||||||
Ok(path_abs_buf) => Cow::Owned(path_abs_buf.as_os_str().to_os_string()),
|
Ok(path_abs_buf) => Cow::Owned(path_abs_buf.as_os_str().to_os_string()),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
print_error_and_exit!("Unable to retrieve absolute path.");
|
print_error_and_exit!("Unable to retrieve absolute path.");
|
||||||
|
@ -361,14 +361,14 @@ fn spawn_senders(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !pattern.is_match(&fshelper::osstr_to_bytes(search_str.as_ref())) {
|
if !pattern.is_match(&filesystem::osstr_to_bytes(search_str.as_ref())) {
|
||||||
return ignore::WalkState::Continue;
|
return ignore::WalkState::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out unwanted extensions.
|
// Filter out unwanted extensions.
|
||||||
if let Some(ref exts_regex) = config.extensions {
|
if let Some(ref exts_regex) = config.extensions {
|
||||||
if let Some(path_str) = entry_path.file_name() {
|
if let Some(path_str) = entry_path.file_name() {
|
||||||
if !exts_regex.is_match(&fshelper::osstr_to_bytes(path_str)) {
|
if !exts_regex.is_match(&filesystem::osstr_to_bytes(path_str)) {
|
||||||
return ignore::WalkState::Continue;
|
return ignore::WalkState::Continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -385,9 +385,9 @@ fn spawn_senders(
|
||||||
|| (file_types.executables_only
|
|| (file_types.executables_only
|
||||||
&& !entry
|
&& !entry
|
||||||
.metadata()
|
.metadata()
|
||||||
.map(|m| fshelper::is_executable(&m))
|
.map(|m| filesystem::is_executable(&m))
|
||||||
.unwrap_or(false))
|
.unwrap_or(false))
|
||||||
|| (file_types.empty_only && !fshelper::is_empty(&entry))
|
|| (file_types.empty_only && !filesystem::is_empty(&entry))
|
||||||
|| !(entry_type.is_file() || entry_type.is_dir() || entry_type.is_symlink())
|
|| !(entry_type.is_file() || entry_type.is_dir() || entry_type.is_symlink())
|
||||||
{
|
{
|
||||||
return ignore::WalkState::Continue;
|
return ignore::WalkState::Continue;
|
||||||
|
|
Loading…
Reference in a new issue