File tree Expand file tree Collapse file tree 6 files changed +26
-1
lines changed Expand file tree Collapse file tree 6 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
- refs/heads/try: 3cb2cd1f7133619761a7c229185f0ab227526181
5
+ refs/heads/try: 6b0c4822c10d1e0824043f81fc9e39096cc40172
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ native mod libc {
62
62
fn mkdir ( path : str:: sbuf , mode : c_int ) -> c_int ;
63
63
fn rmdir ( path : str:: sbuf ) -> c_int ;
64
64
fn chdir ( path : str:: sbuf ) -> c_int ;
65
+ fn unlink ( path : str:: sbuf ) -> c_int ;
65
66
66
67
fn sysctl ( name : * c_int , namelen : c_uint ,
67
68
oldp : * u8 , & oldlenp: size_t ,
Original file line number Diff line number Diff line change @@ -449,6 +449,27 @@ fn homedir() -> option<path> {
449
449
}
450
450
}
451
451
452
+ /*
453
+ Function: remove_file
454
+
455
+ Deletes an existing file.
456
+ */
457
+ fn remove_file ( p : path ) -> bool {
458
+ ret unlink ( p) ;
459
+
460
+ #[ cfg( target_os = "win32" ) ]
461
+ fn unlink ( p : path ) -> bool {
462
+ ret str:: as_buf ( p, { |buf| os:: kernel32:: DeleteFileA ( buf) } ) ;
463
+ }
464
+
465
+ #[ cfg( target_os = "linux" ) ]
466
+ #[ cfg( target_os = "macos" ) ]
467
+ #[ cfg( target_os = "freebsd" ) ]
468
+ fn unlink ( _p : path ) -> bool {
469
+ ret str:: as_buf ( _p, { |buf| os:: libc:: unlink ( buf) == 0i32 } ) ;
470
+ }
471
+ }
472
+
452
473
#[ cfg( test) ]
453
474
mod tests {
454
475
#[ test]
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ native mod libc {
63
63
fn mkdir ( path : str:: sbuf , mode : c_int ) -> c_int ;
64
64
fn rmdir ( path : str:: sbuf ) -> c_int ;
65
65
fn chdir ( path : str:: sbuf ) -> c_int ;
66
+ fn unlink ( path : str:: sbuf ) -> c_int ;
66
67
}
67
68
68
69
mod libc_constants {
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ native mod libc {
55
55
fn mkdir ( s : str:: sbuf , mode : c_int ) -> c_int ;
56
56
fn rmdir ( s : str:: sbuf ) -> c_int ;
57
57
fn chdir ( s : str:: sbuf ) -> c_int ;
58
+ fn unlink ( path : str:: sbuf ) -> c_int ;
58
59
59
60
// FIXME: Needs varags
60
61
fn fcntl ( fd : fd_t , cmd : c_int ) -> c_int ;
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ native mod kernel32 {
62
62
lpSecurityAttributes : LPSECURITY_ATTRIBUTES ) -> bool ;
63
63
fn RemoveDirectoryA ( lpPathName : LPCTSTR ) -> bool ;
64
64
fn SetCurrentDirectoryA ( lpPathName : LPCTSTR ) -> bool ;
65
+ fn DeleteFileA ( lpFileName : LPCTSTR ) -> bool ;
65
66
}
66
67
67
68
// FIXME turn into constants
You can’t perform that action at this time.
0 commit comments