File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -675,7 +675,7 @@ pub fn mkdir_recursive(p: &Path, mode: c_int) -> bool {
675675/// Lists the contents of a directory
676676#[ allow( non_implicitly_copyable_typarams) ]
677677pub fn list_dir ( p : & Path ) -> ~[ ~str ] {
678- if p. components . is_empty ( ) {
678+ if p. components . is_empty ( ) && !p . is_absolute ( ) {
679679 // Not sure what the right behavior is here, but this
680680 // prevents a bounds check failure later
681681 return ~[ ] ;
@@ -1607,6 +1607,20 @@ mod tests {
16071607 assert!(dirs.is_empty());
16081608 }
16091609
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+
16101624 #[ test]
16111625 fn path_is_dir ( ) {
16121626 assert ! ( ( os:: path_is_dir( & Path ( "." ) ) ) ) ;
You can’t perform that action at this time.
0 commit comments