Skip to content

Commit e0f9073

Browse files
committed
Update to rust master
1 parent 3dcfc44 commit e0f9073

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
html_root_url = "http://doc.rust-lang.org/glob/")]
2626
#![cfg_attr(test, deny(warnings))]
2727
#![cfg_attr(all(test, windows), feature(std_misc))]
28-
#![feature(path, io, core, collections, unicode, fs, os)]
28+
#![feature(path, io, core, collections, unicode)]
2929

3030
use std::ascii::AsciiExt;
3131
use std::cell::Cell;
@@ -228,6 +228,10 @@ impl fmt::Display for GlobError {
228228
}
229229
}
230230

231+
fn is_dir(p: &Path) -> bool {
232+
fs::metadata(p).map(|m| m.is_dir()) == Ok(true)
233+
}
234+
231235
/// An alias for a glob iteration result.
232236
///
233237
/// This represents either a matched path or a glob iteration error,
@@ -265,7 +269,7 @@ impl Iterator for Paths {
265269
// idx -1: was already checked by fill_todo, maybe path was '.' or
266270
// '..' that we can't match here because of normalization.
267271
if idx == -1 as usize {
268-
if self.require_dir && !path.is_dir() { continue; }
272+
if self.require_dir && !is_dir(&path) { continue; }
269273
return Some(Ok(path));
270274
}
271275

@@ -279,7 +283,7 @@ impl Iterator for Paths {
279283
}
280284

281285
// the path is a directory, so it's a match
282-
if path.is_dir() {
286+
if is_dir(&path) {
283287
// push this directory's contents
284288
fill_todo(&mut self.todo, self.dir_patterns.as_slice(),
285289
next, &path, &self.options);
@@ -316,7 +320,7 @@ impl Iterator for Paths {
316320
// *AND* its children so we don't need to check the
317321
// children
318322

319-
if !self.require_dir || path.is_dir() {
323+
if !self.require_dir || is_dir(&path) {
320324
return Some(Ok(path));
321325
}
322326
} else {
@@ -727,7 +731,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
727731
};
728732

729733
let pattern = &patterns[idx];
730-
let is_dir = path.is_dir();
734+
let is_dir = is_dir(path);
731735
let curdir = path == Path::new(".");
732736
match pattern_as_str(pattern) {
733737
Some(s) => {
@@ -738,7 +742,7 @@ fn fill_todo(todo: &mut Vec<Result<(PathBuf, usize), GlobError>>,
738742
// right away.
739743
let special = "." == s.as_slice() || ".." == s.as_slice();
740744
let next_path = if curdir {PathBuf::new(&s)} else {path.join(&s)};
741-
if (special && is_dir) || (!special && next_path.exists()) {
745+
if (special && is_dir) || (!special && fs::metadata(&next_path).is_ok()) {
742746
add(todo, next_path);
743747
}
744748
},

tests/glob-std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// ignore-windows TempDir may cause IoError on windows: #10462
1212

13-
#![feature(path, fs)]
13+
#![feature(path)]
1414

1515
extern crate glob;
1616
extern crate tempdir;

0 commit comments

Comments
 (0)