Skip to content
Myr

Move strip_current_dir

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 b415d72 · Browse files · 2 files+16 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−15 removed

  • other:+16 added−15 removed

2 files+16 added−15 removed

modified:src/filesystem.rs+11 added-1 removed
3 unmodified lines
4use std::fs;5use std::io;6#[cfg(any(unix, target_os = "redox"))]7use std::os::unix::fs::PermissionsExt;8use std::path::{Path, PathBuf};8use std::path::{Component, Path, PathBuf};910use crate::walk;1112pub fn path_absolute_form(path: &Path) -> io::Result<PathBuf> {
68 unmodified lines
81 Cow::Owned(string) => Cow::Owned(string.into_bytes()),82 Cow::Borrowed(string) => Cow::Borrowed(string.as_bytes()),83 }84}8586/// Remove the `./` prefix from a path.87pub fn strip_current_dir(pathbuf: &PathBuf) -> &Path {88 let mut iter = pathbuf.components();89 let mut iter_next = iter.clone();90 if iter_next.next() == Some(Component::CurDir) {91 iter.next();92 }93 iter.as_path()94}
modified:src/output.rs+5 added-14 removed
1use crate::exit_codes::ExitCode;2use crate::options::Options;3use lscolors::{LsColors, Style};41use std::borrow::Cow;2use std::io::{self, StdoutLock, Write};7use std::path::{Component, Path, PathBuf};3use std::path::{Path, PathBuf};4use std::process;5use std::sync::atomic::{AtomicBool, Ordering};6use std::sync::Arc;78use ansi_term;9use lscolors::{LsColors, Style};1014/// Remove the `./` prefix from a path.15fn strip_current_dir(pathbuf: &PathBuf) -> &Path {16 let mut iter = pathbuf.components();17 let mut iter_next = iter.clone();18 if iter_next.next() == Some(Component::CurDir) {19 iter.next();20 }21 iter.as_path()22}11use crate::exit_codes::ExitCode;12use crate::filesystem::strip_current_dir;13use crate::options::Options;1415pub fn print_entry(16 stdout: &mut StdoutLock,17 entry: &PathBuf,
73 unmodified lines