@@ -479,25 +479,29 @@ pub trait FileSystemInfo {
479
479
///
480
480
/// * Check if a file exists, reading from it if so
481
481
///
482
- /// use std;
483
- /// use std::path::Path;
484
- /// use std::rt::io::file::{FileInfo, FileReader};
485
- ///
486
- /// let f = &Path("/some/file/path.txt");
487
- /// if f.exists() {
488
- /// let reader = f.open_reader(Open);
489
- /// let mut mem = [0u8, 8*64000];
490
- /// reader.read(mem);
491
- /// // ...
492
- /// }
482
+ /// ~~~{.rust}
483
+ /// use std;
484
+ /// use std::path::Path;
485
+ /// use std::rt::io::file::{FileInfo, FileReader};
486
+ ///
487
+ /// let f = &Path("/some/file/path.txt");
488
+ /// if f.exists() {
489
+ /// let reader = f.open_reader(Open);
490
+ /// let mut mem = [0u8, 8*64000];
491
+ /// reader.read(mem);
492
+ /// // ...
493
+ /// }
494
+ /// ~~~
493
495
///
494
496
/// * Is the given path a file?
495
497
///
496
- /// let f = get_file_path_from_wherever();
497
- /// match f.is_file() {
498
- /// true => doing_something_with_a_file(f),
499
- /// _ => {}
500
- /// }
498
+ /// ~~~{.rust}
499
+ /// let f = get_file_path_from_wherever();
500
+ /// match f.is_file() {
501
+ /// true => doing_something_with_a_file(f),
502
+ /// _ => {}
503
+ /// }
504
+ /// ~~~
501
505
pub trait FileInfo : FileSystemInfo {
502
506
/// Whether the underlying implemention (be it a file path,
503
507
/// or something else) points at a "regular file" on the FS. Will return
@@ -572,27 +576,31 @@ impl FileInfo for Path { }
572
576
///
573
577
/// * Check if a directory exists, `mkdir`'ing it if not
574
578
///
575
- /// use std;
576
- /// use std::path::Path;
577
- /// use std::rt::io::file::{DirectoryInfo};
579
+ /// ~~~{.rust}
580
+ /// use std;
581
+ /// use std::path::Path;
582
+ /// use std::rt::io::file::{DirectoryInfo};
578
583
///
579
- /// let dir = &Path("/some/dir");
580
- /// if !dir.exists() {
581
- /// dir.mkdir();
582
- /// }
584
+ /// let dir = &Path("/some/dir");
585
+ /// if !dir.exists() {
586
+ /// dir.mkdir();
587
+ /// }
588
+ /// ~~~
583
589
///
584
590
/// * Is the given path a directory? If so, iterate on its contents
585
591
///
586
- /// fn visit_dirs(dir: &Path, cb: &fn(&Path)) {
587
- /// if dir.is_dir( ) {
588
- /// let contents = dir.readdir();
589
- /// for entry in contents.iter() {
590
- /// if entry.is_dir () { visit_dirs(entry, cb); }
591
- /// else { cb (entry); }
592
- /// }
592
+ /// ~~~{.rust}
593
+ /// fn visit_dirs(dir: &Path, cb: &fn(&Path) ) {
594
+ /// if dir.is_dir() {
595
+ /// let contents = dir.readdir();
596
+ /// for entry in contents.iter () {
597
+ /// if entry.is_dir() { visit_dirs (entry, cb ); }
598
+ /// else { cb(entry); }
593
599
/// }
594
- /// else { fail!("nope"); }
595
600
/// }
601
+ /// else { fail!("nope"); }
602
+ /// }
603
+ /// ~~~
596
604
trait DirectoryInfo : FileSystemInfo {
597
605
/// Whether the underlying implemention (be it a file path,
598
606
/// or something else) is pointing at a directory in the underlying FS.
@@ -678,7 +686,8 @@ trait DirectoryInfo : FileSystemInfo {
678
686
/// `DirectoryInfo` impl for `path::Path`
679
687
impl DirectoryInfo for Path { }
680
688
681
- fn file_test_smoke_test_impl ( ) {
689
+ #[ test]
690
+ fn file_test_io_smoke_test ( ) {
682
691
do run_in_mt_newsched_task {
683
692
let message = "it's alright. have a good time" ;
684
693
let filename = & Path ( "./tmp/file_rt_io_file_test.txt" ) ;
@@ -701,11 +710,7 @@ fn file_test_smoke_test_impl() {
701
710
}
702
711
703
712
#[ test]
704
- fn file_test_io_smoke_test ( ) {
705
- file_test_smoke_test_impl ( ) ;
706
- }
707
-
708
- fn file_test_invalid_path_opened_without_create_should_raise_condition_impl ( ) {
713
+ fn file_test_io_invalid_path_opened_without_create_should_raise_condition ( ) {
709
714
do run_in_mt_newsched_task {
710
715
let filename = & Path ( "./tmp/file_that_does_not_exist.txt" ) ;
711
716
let mut called = false ;
@@ -718,12 +723,9 @@ fn file_test_invalid_path_opened_without_create_should_raise_condition_impl() {
718
723
assert ! ( called) ;
719
724
}
720
725
}
721
- #[ test]
722
- fn file_test_io_invalid_path_opened_without_create_should_raise_condition ( ) {
723
- file_test_invalid_path_opened_without_create_should_raise_condition_impl ( ) ;
724
- }
725
726
726
- fn file_test_unlinking_invalid_path_should_raise_condition_impl ( ) {
727
+ #[ test]
728
+ fn file_test_iounlinking_invalid_path_should_raise_condition ( ) {
727
729
do run_in_mt_newsched_task {
728
730
let filename = & Path ( "./tmp/file_another_file_that_does_not_exist.txt" ) ;
729
731
let mut called = false ;
@@ -735,12 +737,9 @@ fn file_test_unlinking_invalid_path_should_raise_condition_impl() {
735
737
assert ! ( called) ;
736
738
}
737
739
}
738
- #[ test]
739
- fn file_test_iounlinking_invalid_path_should_raise_condition ( ) {
740
- file_test_unlinking_invalid_path_should_raise_condition_impl ( ) ;
741
- }
742
740
743
- fn file_test_io_non_positional_read_impl ( ) {
741
+ #[ test]
742
+ fn file_test_io_non_positional_read ( ) {
744
743
do run_in_mt_newsched_task {
745
744
use str;
746
745
let message = "ten-four" ;
@@ -768,11 +767,7 @@ fn file_test_io_non_positional_read_impl() {
768
767
}
769
768
770
769
#[ test]
771
- fn file_test_io_non_positional_read ( ) {
772
- file_test_io_non_positional_read_impl ( ) ;
773
- }
774
-
775
- fn file_test_io_seeking_impl ( ) {
770
+ fn file_test_io_seek_and_tell_smoke_test ( ) {
776
771
do run_in_mt_newsched_task {
777
772
use str;
778
773
let message = "ten-four" ;
@@ -801,11 +796,7 @@ fn file_test_io_seeking_impl() {
801
796
}
802
797
803
798
#[ test]
804
- fn file_test_io_seek_and_tell_smoke_test ( ) {
805
- file_test_io_seeking_impl ( ) ;
806
- }
807
-
808
- fn file_test_io_seek_and_write_impl ( ) {
799
+ fn file_test_io_seek_and_write ( ) {
809
800
do run_in_mt_newsched_task {
810
801
use str;
811
802
let initial_msg = "food-is-yummy" ;
@@ -831,11 +822,7 @@ fn file_test_io_seek_and_write_impl() {
831
822
}
832
823
833
824
#[ test]
834
- fn file_test_io_seek_and_write ( ) {
835
- file_test_io_seek_and_write_impl ( ) ;
836
- }
837
-
838
- fn file_test_io_seek_shakedown_impl ( ) {
825
+ fn file_test_io_seek_shakedown ( ) {
839
826
do run_in_mt_newsched_task {
840
827
use str; // 01234567890123
841
828
let initial_msg = "qwer-asdf-zxcv" ;
@@ -870,11 +857,6 @@ fn file_test_io_seek_shakedown_impl() {
870
857
}
871
858
}
872
859
873
- #[ test]
874
- fn file_test_io_seek_shakedown ( ) {
875
- file_test_io_seek_shakedown_impl ( ) ;
876
- }
877
-
878
860
#[ test]
879
861
fn file_test_stat_is_correct_on_is_file ( ) {
880
862
do run_in_mt_newsched_task {
0 commit comments