diff options
author | Andrew Gallant <jamslam@gmail.com> | 2016-09-17 12:54:44 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-09-17 12:54:46 -0400 |
commit | bfbbfbf9797d3b495cf107d93a5f7f027a9b6d16 (patch) | |
tree | 7606ce2c1fc7325650f8bf80ec5c79f60cbddda1 | |
parent | 403ba5fdc8cf9b8ba7efa80398da4f95fa8cc425 (diff) |
fix windows build
Why isn't CI running on each push? It seems to only be running on tagged
commits.
-rw-r--r-- | src/args.rs | 4 | ||||
-rw-r--r-- | src/out.rs | 1 | ||||
-rw-r--r-- | src/pathutil.rs | 14 |
3 files changed, 12 insertions, 7 deletions
diff --git a/src/args.rs b/src/args.rs index 0c9895fd..98c4afeb 100644 --- a/src/args.rs +++ b/src/args.rs @@ -9,7 +9,9 @@ use grep::{Grep, GrepBuilder}; use log; use num_cpus; use regex; -use term::{self, Terminal}; +use term::Terminal; +#[cfg(not(windows))] +use term; #[cfg(windows)] use term::WinConsole; use walkdir::WalkDir; @@ -1,6 +1,7 @@ use std::io::{self, Write}; use term::{self, Terminal}; +#[cfg(not(windows))] use term::terminfo::TermInfo; #[cfg(windows)] use term::WinConsole; diff --git a/src/pathutil.rs b/src/pathutil.rs index 01342ac0..ba4b17bd 100644 --- a/src/pathutil.rs +++ b/src/pathutil.rs @@ -11,14 +11,12 @@ improvement on just listing the files to search (!). use std::ffi::OsStr; use std::path::Path; -use memchr::memrchr; - /// Strip `prefix` from the `path` and return the remainder. /// /// If `path` doesn't have a prefix `prefix`, then return `None`. #[cfg(unix)] -pub fn strip_prefix<'a, P: AsRef<Path>>( - prefix: P, +pub fn strip_prefix<'a, P: AsRef<Path> + ?Sized>( + prefix: &'a P, path: &'a Path, ) -> Option<&'a Path> { use std::os::unix::ffi::OsStrExt; @@ -36,7 +34,10 @@ pub fn strip_prefix<'a, P: AsRef<Path>>( /// /// If `path` doesn't have a prefix `prefix`, then return `None`. #[cfg(not(unix))] -pub fn strip_prefix<'a>(prefix: &Path, path: &'a Path) -> Option<&'a Path> { +pub fn strip_prefix<'a, P: AsRef<Path> + ?Sized>( + prefix: &'a P, + path: &'a Path, +) -> Option<&'a Path> { path.strip_prefix(prefix).ok() } @@ -49,6 +50,7 @@ pub fn file_name<'a, P: AsRef<Path> + ?Sized>( path: &'a P, ) -> Option<&'a OsStr> { use std::os::unix::ffi::OsStrExt; + use memchr::memrchr; let path = path.as_ref().as_os_str().as_bytes(); if path.is_empty() { @@ -90,7 +92,7 @@ pub fn is_hidden<P: AsRef<Path>>(path: P) -> bool { /// Returns true if and only if this file path is considered to be hidden. #[cfg(not(unix))] pub fn is_hidden<P: AsRef<Path>>(path: P) -> bool { - if let Some(name) = file_name(path) { + if let Some(name) = file_name(path.as_ref()) { name.to_str().map(|s| s.starts_with(".")).unwrap_or(false) } else { false |