Remove 'internal' module
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by David Peter · parent 342d12d · Browse files · 4 files·+20 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+20 added−22 removed
- other:+20 added−22 removed
Provenance
- Commit
e0cba4b- Tree
5f0b0d7- Author
sharkdp <davidpeter@web.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
342d12d
4 files changed+20 added−22 removed
modified:src/fshelper/mod.rs+18 added
1+use std::borrow::Cow;2 use std::env::current_dir;3+use std::ffi::OsStr;4 use std::fs;5 use std::io;6 #[cfg(any(unix, target_os = "redox"))]7 use std::os::unix::fs::PermissionsExt;57 unmodified lines65 } else {66 false67 }68 }69+70+#[cfg(any(unix, target_os = "redox"))]71+pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {72+ use std::os::unix::ffi::OsStrExt;73+ Cow::Borrowed(input.as_bytes())74+}75+76+#[cfg(windows)]77+pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {78+ let string = input.to_string_lossy();79+80+ match string {81+ Cow::Owned(string) => Cow::Owned(string.into_bytes()),82+ Cow::Borrowed(string) => Cow::Borrowed(string.as_bytes()),83+ }84+}deleted:src/internal/mod.rs-18 removed
1-use std::borrow::Cow;2-use std::ffi::OsStr;3-4-#[cfg(any(unix, target_os = "redox"))]5-pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {6- use std::os::unix::ffi::OsStrExt;7- Cow::Borrowed(input.as_bytes())8-}9-10-#[cfg(windows)]11-pub fn osstr_to_bytes(input: &OsStr) -> Cow<[u8]> {12- let string = input.to_string_lossy();13-14- match string {15- Cow::Owned(string) => Cow::Owned(string.into_bytes()),16- Cow::Borrowed(string) => Cow::Borrowed(string.as_bytes()),17- }18-}modified:src/main.rs-1 removed
5 unmodified lines6 mod exit_codes;7 mod filetypes;8 mod filter;9 mod fshelper;10-mod internal;10 mod options;11 mod output;12 mod regex_helper;13 mod walk;305 unmodified linesmodified:src/walk.rs+2 added-3 removed
1 use crate::exec;2 use crate::exit_codes::{merge_exitcodes, ExitCode};3 use crate::fshelper;4-use crate::internal::osstr_to_bytes;4 use crate::options::Options;5 use crate::output;6 7 use std::borrow::Cow;352 unmodified lines360 ),361 }362 };363 365- if !pattern.is_match(&osstr_to_bytes(search_str.as_ref())) {364+ if !pattern.is_match(&fshelper::osstr_to_bytes(search_str.as_ref())) {365 return ignore::WalkState::Continue;366 }367 368 // Filter out unwanted extensions.369 if let Some(ref exts_regex) = config.extensions {370 if let Some(path_str) = entry_path.file_name() {372- if !exts_regex.is_match(&osstr_to_bytes(path_str)) {371+ if !exts_regex.is_match(&fshelper::osstr_to_bytes(path_str)) {372 return ignore::WalkState::Continue;373 }374 } else {375 return ignore::WalkState::Continue;70 unmodified lines