summaryrefslogtreecommitdiffstats
path: root/src/pathutil.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-09-17 12:54:44 -0400
committerAndrew Gallant <jamslam@gmail.com>2016-09-17 12:54:46 -0400
commitbfbbfbf9797d3b495cf107d93a5f7f027a9b6d16 (patch)
tree7606ce2c1fc7325650f8bf80ec5c79f60cbddda1 /src/pathutil.rs
parent403ba5fdc8cf9b8ba7efa80398da4f95fa8cc425 (diff)
fix windows build
Why isn't CI running on each push? It seems to only be running on tagged commits.
Diffstat (limited to 'src/pathutil.rs')
-rw-r--r--src/pathutil.rs14
1 files changed, 8 insertions, 6 deletions
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