1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// mod mio
use io;
use *;
//-------------------------------------------------------------------
/*
use std::fs::{File, OpenOptions};
use std::path::Path;
pub fn with_file<A>( get_resource: fn(()) -> io::Result<File>,
file_action: fn(&mut File) -> io::Result<A>)
-> io::Result<A> {
let mut handle = get_resource( ())? ;
file_action( &mut handle)
}
pub fn open_rd( fname: &str) -> io::Result<File> {
let path = Path::new( fname);
File::open( path)
}
pub fn open_wr( fname: &str) -> io::Result<File> {
let path = Path::new( fname);
OpenOptions::new().write(true)
.truncate(true) // truncate if it exists
.create(true) // create if it does'nt exist
.open( path)
}
*/