@@ -4,55 +4,14 @@ use std::{
4
4
cell:: RefCell ,
5
5
env,
6
6
ffi:: OsString ,
7
- io:: Write ,
7
+ io:: { self , Write } ,
8
8
path:: { Path , PathBuf } ,
9
9
process:: { Command , Stdio } ,
10
10
} ;
11
11
12
12
use anyhow:: { bail, Context , Result } ;
13
13
14
- pub mod fs2 {
15
- use std:: { fs, path:: Path } ;
16
-
17
- use anyhow:: { Context , Result } ;
18
-
19
- pub fn read_dir < P : AsRef < Path > > ( path : P ) -> Result < fs:: ReadDir > {
20
- let path = path. as_ref ( ) ;
21
- fs:: read_dir ( path) . with_context ( || format ! ( "Failed to read {}" , path. display( ) ) )
22
- }
23
-
24
- pub fn read_to_string < P : AsRef < Path > > ( path : P ) -> Result < String > {
25
- let path = path. as_ref ( ) ;
26
- fs:: read_to_string ( path) . with_context ( || format ! ( "Failed to read {}" , path. display( ) ) )
27
- }
28
-
29
- pub fn write < P : AsRef < Path > , C : AsRef < [ u8 ] > > ( path : P , contents : C ) -> Result < ( ) > {
30
- let path = path. as_ref ( ) ;
31
- fs:: write ( path, contents) . with_context ( || format ! ( "Failed to write {}" , path. display( ) ) )
32
- }
33
-
34
- pub fn copy < P : AsRef < Path > , Q : AsRef < Path > > ( from : P , to : Q ) -> Result < u64 > {
35
- let from = from. as_ref ( ) ;
36
- let to = to. as_ref ( ) ;
37
- fs:: copy ( from, to)
38
- . with_context ( || format ! ( "Failed to copy {} to {}" , from. display( ) , to. display( ) ) )
39
- }
40
-
41
- pub fn remove_file < P : AsRef < Path > > ( path : P ) -> Result < ( ) > {
42
- let path = path. as_ref ( ) ;
43
- fs:: remove_file ( path) . with_context ( || format ! ( "Failed to remove file {}" , path. display( ) ) )
44
- }
45
-
46
- pub fn remove_dir_all < P : AsRef < Path > > ( path : P ) -> Result < ( ) > {
47
- let path = path. as_ref ( ) ;
48
- fs:: remove_dir_all ( path) . with_context ( || format ! ( "Failed to remove dir {}" , path. display( ) ) )
49
- }
50
-
51
- pub fn create_dir_all < P : AsRef < Path > > ( path : P ) -> Result < ( ) > {
52
- let path = path. as_ref ( ) ;
53
- fs:: create_dir_all ( path) . with_context ( || format ! ( "Failed to create dir {}" , path. display( ) ) )
54
- }
55
- }
14
+ pub use fs_err as fs2;
56
15
57
16
#[ macro_export]
58
17
macro_rules! run {
@@ -98,7 +57,7 @@ impl Drop for Pushenv {
98
57
}
99
58
}
100
59
101
- pub fn rm_rf ( path : impl AsRef < Path > ) -> Result < ( ) > {
60
+ pub fn rm_rf ( path : impl AsRef < Path > ) -> io :: Result < ( ) > {
102
61
let path = path. as_ref ( ) ;
103
62
if !path. exists ( ) {
104
63
return Ok ( ( ) ) ;
0 commit comments