From bfbbfbf9797d3b495cf107d93a5f7f027a9b6d16 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 17 Sep 2016 12:54:44 -0400 Subject: [PATCH] fix windows build Why isn't CI running on each push? It seems to only be running on tagged commits. --- src/args.rs | 4 +++- src/out.rs | 1 + src/pathutil.rs | 14 ++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/args.rs b/src/args.rs index 0c9895f..98c4afe 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; diff --git a/src/out.rs b/src/out.rs index 384e227..32b581b 100644 --- a/src/out.rs +++ b/src/out.rs @@ -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 01342ac..ba4b17b 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>( - prefix: P, +pub fn strip_prefix<'a, P: AsRef + ?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>( /// /// 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 + ?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 + ?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>(path: P) -> bool { /// Returns true if and only if this file path is considered to be hidden. #[cfg(not(unix))] pub fn is_hidden>(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