mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-18 01:40:34 +01:00
Remove 'internal' module
This commit is contained in:
parent
342d12db3f
commit
e0cba4b700
4 changed files with 20 additions and 22 deletions
|
@ -1,4 +1,6 @@
|
|||
use std::borrow::Cow;
|
||||
use std::env::current_dir;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
|
@ -64,3 +66,19 @@ pub fn is_empty(entry: &walk::DirEntry) -> bool {
|
|||
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 filter;
|
||||
mod fshelper;
|
||||
mod internal;
|
||||
mod options;
|
||||
mod output;
|
||||
mod regex_helper;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::exec;
|
||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||
use crate::fshelper;
|
||||
use crate::internal::osstr_to_bytes;
|
||||
use crate::options::Options;
|
||||
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;
|
||||
}
|
||||
|
||||
// Filter out unwanted extensions.
|
||||
if let Some(ref exts_regex) = config.extensions {
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue