mirror of https://github.com/sharkdp/fd.git
Remove 'internal' module
This commit is contained in:
parent
342d12db3f
commit
e0cba4b700
|
@ -1,4 +1,6 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::env::current_dir;
|
use std::env::current_dir;
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
#[cfg(any(unix, target_os = "redox"))]
|
#[cfg(any(unix, target_os = "redox"))]
|
||||||
|
@ -64,3 +66,19 @@ pub fn is_empty(entry: &walk::DirEntry) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(unix, target_os = "redox"))]
|
||||||
|
pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {
|
||||||
|
use std::os::unix::ffi::OsStrExt;
|
||||||
|
Cow::Borrowed(input.as_bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {
|
||||||
|
let string = input.to_string_lossy();
|
||||||
|
|
||||||
|
match string {
|
||||||
|
Cow::Owned(string) => Cow::Owned(string.into_bytes()),
|
||||||
|
Cow::Borrowed(string) => Cow::Borrowed(string.as_bytes()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::ffi::OsStr;
|
|
||||||
|
|
||||||
#[cfg(any(unix, target_os = "redox"))]
|
|
||||||
pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {
|
|
||||||
use std::os::unix::ffi::OsStrExt;
|
|
||||||
Cow::Borrowed(input.as_bytes())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {
|
|
||||||
let string = input.to_string_lossy();
|
|
||||||
|
|
||||||
match string {
|
|
||||||
Cow::Owned(string) => Cow::Owned(string.into_bytes()),
|
|
||||||
Cow::Borrowed(string) => Cow::Borrowed(string.as_bytes()),
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ mod exit_codes;
|
||||||
mod filetypes;
|
mod filetypes;
|
||||||
mod filter;
|
mod filter;
|
||||||
mod fshelper;
|
mod fshelper;
|
||||||
mod internal;
|
|
||||||
mod options;
|
mod options;
|
||||||
mod output;
|
mod output;
|
||||||
mod regex_helper;
|
mod regex_helper;
|
||||||
|
|
|
@ -1,7 +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::fshelper;
|
||||||
use crate::internal::osstr_to_bytes;
|
|
||||||
use crate::options::Options;
|
use crate::options::Options;
|
||||||
use crate::output;
|
use crate::output;
|
||||||
|
|
||||||
|
@ -362,14 +361,14 @@ fn spawn_senders(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !pattern.is_match(&osstr_to_bytes(search_str.as_ref())) {
|
if !pattern.is_match(&fshelper::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(&osstr_to_bytes(path_str)) {
|
if !exts_regex.is_match(&fshelper::osstr_to_bytes(path_str)) {
|
||||||
return ignore::WalkState::Continue;
|
return ignore::WalkState::Continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue