Skip to content

Commit 0613fc8

Browse files
committed
---
yaml --- r: 141239 b: refs/heads/try2 c: f254d11 h: refs/heads/master i: 141237: 33ba5e3 141235: 1491177 141231: e4d5449 v: v3
1 parent 50d59f7 commit 0613fc8

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2c2346e3d4f999b95a56444d978c3ea792828263
8+
refs/heads/try2: f254d119eab514c91fbd6590fba821ec7a0bfd7f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/os.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,11 @@ pub fn mkdir_recursive(p: &Path, mode: c_int) -> bool {
675675
/// Lists the contents of a directory
676676
#[allow(non_implicitly_copyable_typarams)]
677677
pub fn list_dir(p: &Path) -> ~[~str] {
678+
if p.components.is_empty() && !p.is_absolute() {
679+
// Not sure what the right behavior is here, but this
680+
// prevents a bounds check failure later
681+
return ~[];
682+
}
678683
unsafe {
679684
#[cfg(target_os = "linux")]
680685
#[cfg(target_os = "android")]
@@ -1596,6 +1601,26 @@ mod tests {
15961601
}
15971602
}
15981603
1604+
#[test]
1605+
fn list_dir_empty_path() {
1606+
let dirs = os::list_dir(&Path(""));
1607+
assert!(dirs.is_empty());
1608+
}
1609+
1610+
#[test]
1611+
#[cfg(not(windows))]
1612+
fn list_dir_root() {
1613+
let dirs = os::list_dir(&Path("/"));
1614+
assert!(dirs.len() > 1);
1615+
}
1616+
#[test]
1617+
#[cfg(windows)]
1618+
fn list_dir_root() {
1619+
let dirs = os::list_dir(&Path("C:\\"));
1620+
assert!(dirs.len() > 1);
1621+
}
1622+
1623+
15991624
#[test]
16001625
fn path_is_dir() {
16011626
assert!((os::path_is_dir(&Path("."))));

0 commit comments

Comments
 (0)