16
16
* to write OS-ignorant code by default.
17
17
*/
18
18
19
- #[ forbid( deprecated_mode) ] ;
20
- #[ forbid( deprecated_pattern) ] ;
21
-
22
19
import libc:: { c_char, c_void, c_int, c_uint, size_t, ssize_t,
23
20
mode_t, pid_t, FILE } ;
24
21
import libc:: { close, fclose} ;
@@ -56,7 +53,7 @@ extern mod rustrt {
56
53
57
54
const tmpbuf_sz : uint = 1000 u;
58
55
59
- fn as_c_charp < T > ( + s : ~str , f : fn ( * c_char ) -> T ) -> T {
56
+ fn as_c_charp < T > ( s : ~str , f : fn ( * c_char ) -> T ) -> T {
60
57
str:: as_c_str ( s, |b| f ( b as * c_char ) )
61
58
}
62
59
@@ -106,19 +103,19 @@ mod win32 {
106
103
return res;
107
104
}
108
105
109
- fn as_utf16_p < T > ( + s : ~str , f : fn ( * u16 ) -> T ) -> T {
106
+ fn as_utf16_p < T > ( s : ~str , f : fn ( * u16 ) -> T ) -> T {
110
107
let mut t = str:: to_utf16 ( s) ;
111
108
// Null terminate before passing on.
112
109
t += ~[ 0u16 ] ;
113
110
vec:: as_buf ( t, |buf, _len| f ( buf) )
114
111
}
115
112
}
116
113
117
- fn getenv ( + n : ~str ) -> option < ~str > {
114
+ fn getenv ( n : ~str ) -> option < ~str > {
118
115
global_env:: getenv ( n)
119
116
}
120
117
121
- fn setenv ( + n : ~str , + v : ~str ) {
118
+ fn setenv ( n : ~str , v : ~str ) {
122
119
global_env:: setenv ( n, v)
123
120
}
124
121
@@ -143,14 +140,14 @@ mod global_env {
143
140
MsgEnv ( comm:: Chan < ~[ ( ~str , ~str ) ] > )
144
141
}
145
142
146
- fn getenv ( + n : ~str ) -> option < ~str > {
143
+ fn getenv ( n : ~str ) -> option < ~str > {
147
144
let env_ch = get_global_env_chan ( ) ;
148
145
let po = comm:: port ( ) ;
149
146
comm:: send ( env_ch, MsgGetEnv ( n, comm:: chan ( po) ) ) ;
150
147
comm:: recv ( po)
151
148
}
152
149
153
- fn setenv ( + n : ~str , + v : ~str ) {
150
+ fn setenv ( n : ~str , v : ~str ) {
154
151
let env_ch = get_global_env_chan ( ) ;
155
152
let po = comm:: port ( ) ;
156
153
comm:: send ( env_ch, MsgSetEnv ( n, v, comm:: chan ( po) ) ) ;
@@ -212,7 +209,7 @@ mod global_env {
212
209
}
213
210
214
211
#[ cfg( unix) ]
215
- fn getenv ( + n : ~str ) -> option < ~str > {
212
+ fn getenv ( n : ~str ) -> option < ~str > {
216
213
unsafe {
217
214
let s = str:: as_c_str ( n, libc:: getenv) ;
218
215
return if unsafe :: reinterpret_cast ( s) == 0 {
@@ -225,7 +222,7 @@ mod global_env {
225
222
}
226
223
227
224
#[ cfg( windows) ]
228
- fn getenv ( + n : ~str ) -> option < ~str > {
225
+ fn getenv ( n : ~str ) -> option < ~str > {
229
226
import libc:: types:: os:: arch:: extra:: * ;
230
227
import libc:: funcs:: extra:: kernel32:: * ;
231
228
import win32:: * ;
@@ -238,7 +235,7 @@ mod global_env {
238
235
239
236
240
237
#[ cfg( unix) ]
241
- fn setenv ( + n : ~str , + v : ~str ) {
238
+ fn setenv ( n : ~str , v : ~str ) {
242
239
243
240
// FIXME: remove this when export globs work properly. #1238
244
241
import libc:: funcs:: posix01:: unistd:: setenv;
@@ -251,7 +248,7 @@ mod global_env {
251
248
252
249
253
250
#[ cfg( windows) ]
254
- fn setenv ( + n : ~str , + v : ~str ) {
251
+ fn setenv ( n : ~str , v : ~str ) {
255
252
// FIXME: remove imports when export globs work properly. #1238
256
253
import libc:: funcs:: extra:: kernel32:: * ;
257
254
import win32:: * ;
@@ -361,7 +358,7 @@ fn pipe() -> {in: c_int, out: c_int} {
361
358
}
362
359
363
360
364
- fn dll_filename ( + base : ~str ) -> ~str {
361
+ fn dll_filename ( base : ~str ) -> ~str {
365
362
return pre ( ) + base + dll_suffix ( ) ;
366
363
367
364
#[ cfg( unix) ]
@@ -468,11 +465,11 @@ fn homedir() -> option<Path> {
468
465
}
469
466
470
467
/// Recursively walk a directory structure
471
- fn walk_dir( + p : Path , f : fn ( Path ) -> bool ) {
468
+ fn walk_dir( p : Path , f : fn ( Path ) -> bool ) {
472
469
473
470
walk_dir_ ( p, f) ;
474
471
475
- fn walk_dir_ ( + p : Path , f : fn ( Path ) -> bool ) -> bool {
472
+ fn walk_dir_ ( p : Path , f : fn ( Path ) -> bool ) -> bool {
476
473
let mut keepgoing = true ;
477
474
do list_dir( p) . each |q| {
478
475
let path = path:: connect ( p, q) ;
@@ -497,14 +494,14 @@ fn walk_dir(+p: Path, f: fn(Path) -> bool) {
497
494
}
498
495
499
496
/// Indicates whether a path represents a directory
500
- fn path_is_dir ( + p : Path ) -> bool {
497
+ fn path_is_dir ( p : Path ) -> bool {
501
498
do str:: as_c_str ( p) |buf| {
502
499
rustrt:: rust_path_is_dir ( buf) != 0 as c_int
503
500
}
504
501
}
505
502
506
503
/// Indicates whether a path exists
507
- fn path_exists ( + p : Path ) -> bool {
504
+ fn path_exists ( p : Path ) -> bool {
508
505
do str:: as_c_str ( p) |buf| {
509
506
rustrt:: rust_path_exists ( buf) != 0 as c_int
510
507
}
@@ -522,7 +519,7 @@ fn path_exists(+p: Path) -> bool {
522
519
// NB: this is here rather than in path because it is a form of environment
523
520
// querying; what it does depends on the process working directory, not just
524
521
// the input paths.
525
- fn make_absolute ( + p : Path ) -> Path {
522
+ fn make_absolute ( p : Path ) -> Path {
526
523
if path:: path_is_absolute ( p) {
527
524
p
528
525
} else {
@@ -532,11 +529,11 @@ fn make_absolute(+p: Path) -> Path {
532
529
533
530
534
531
/// Creates a directory at the specified path
535
- fn make_dir ( + p : Path , mode : c_int ) -> bool {
532
+ fn make_dir ( p : Path , mode : c_int ) -> bool {
536
533
return mkdir ( p, mode) ;
537
534
538
535
#[ cfg( windows) ]
539
- fn mkdir ( + p : Path , _mode : c_int ) -> bool {
536
+ fn mkdir ( p : Path , _mode : c_int ) -> bool {
540
537
// FIXME: remove imports when export globs work properly. #1238
541
538
import libc:: types:: os:: arch:: extra:: * ;
542
539
import libc:: funcs:: extra:: kernel32:: * ;
@@ -549,21 +546,21 @@ fn make_dir(+p: Path, mode: c_int) -> bool {
549
546
}
550
547
551
548
#[ cfg( unix) ]
552
- fn mkdir ( + p : Path , mode : c_int ) -> bool {
549
+ fn mkdir ( p : Path , mode : c_int ) -> bool {
553
550
do as_c_charp ( p) |c| {
554
551
libc:: mkdir ( c, mode as mode_t ) == ( 0 as c_int )
555
552
}
556
553
}
557
554
}
558
555
559
556
/// Lists the contents of a directory
560
- fn list_dir( + p : Path ) -> ~[ ~str ] {
557
+ fn list_dir( p : Path ) -> ~[ ~str ] {
561
558
562
559
#[ cfg( unix) ]
563
- fn star ( + p : ~str ) -> ~str { p }
560
+ fn star ( p : ~str ) -> ~str { p }
564
561
565
562
#[ cfg( windows) ]
566
- fn star( + p : ~str ) -> ~str {
563
+ fn star( p : ~str ) -> ~str {
567
564
let pl = str:: len ( p) ;
568
565
if pl == 0 u || ( p[ pl - 1 u] as char != path:: consts:: path_sep
569
566
|| p[ pl - 1 u] as char != path:: consts:: alt_path_sep) {
@@ -583,7 +580,7 @@ fn list_dir(+p: Path) -> ~[~str] {
583
580
*
584
581
* This version prepends each entry with the directory.
585
582
*/
586
- fn list_dir_path(+ p: Path) -> ~[~str] {
583
+ fn list_dir_path(p: Path) -> ~[~str] {
587
584
let mut p = p;
588
585
let pl = str::len(p);
589
586
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
@@ -594,11 +591,11 @@ fn list_dir_path(+p: Path) -> ~[~str] {
594
591
}
595
592
596
593
/// Removes a directory at the specified path
597
- fn remove_dir(+ p: Path) -> bool {
594
+ fn remove_dir(p: Path) -> bool {
598
595
return rmdir(p);
599
596
600
597
#[cfg(windows)]
601
- fn rmdir(+ p: Path) -> bool {
598
+ fn rmdir(p: Path) -> bool {
602
599
// FIXME: remove imports when export globs work properly. #1238
603
600
import libc::funcs::extra::kernel32::*;
604
601
import libc::types::os::arch::extra::*;
@@ -609,18 +606,18 @@ fn remove_dir(+p: Path) -> bool {
609
606
}
610
607
611
608
#[cfg(unix)]
612
- fn rmdir(+ p: Path) -> bool {
609
+ fn rmdir(p: Path) -> bool {
613
610
return do as_c_charp(p) |buf| {
614
611
libc::rmdir(buf) == (0 as c_int)
615
612
};
616
613
}
617
614
}
618
615
619
- fn change_dir(+ p: Path) -> bool {
616
+ fn change_dir(p: Path) -> bool {
620
617
return chdir(p);
621
618
622
619
#[cfg(windows)]
623
- fn chdir(+ p: Path) -> bool {
620
+ fn chdir(p: Path) -> bool {
624
621
// FIXME: remove imports when export globs work properly. #1238
625
622
import libc::funcs::extra::kernel32::*;
626
623
import libc::types::os::arch::extra::*;
@@ -631,19 +628,19 @@ fn change_dir(+p: Path) -> bool {
631
628
}
632
629
633
630
#[cfg(unix)]
634
- fn chdir(+ p: Path) -> bool {
631
+ fn chdir(p: Path) -> bool {
635
632
return do as_c_charp(p) |buf| {
636
633
libc::chdir(buf) == (0 as c_int)
637
634
};
638
635
}
639
636
}
640
637
641
638
/// Copies a file from one location to another
642
- fn copy_file(+ from: Path, + to: Path) -> bool {
639
+ fn copy_file(from: Path, to: Path) -> bool {
643
640
return do_copy_file(from, to);
644
641
645
642
#[cfg(windows)]
646
- fn do_copy_file(+ from: Path, + to: Path) -> bool {
643
+ fn do_copy_file(from: Path, to: Path) -> bool {
647
644
// FIXME: remove imports when export globs work properly. #1238
648
645
import libc::funcs::extra::kernel32::*;
649
646
import libc::types::os::arch::extra::*;
@@ -656,7 +653,7 @@ fn copy_file(+from: Path, +to: Path) -> bool {
656
653
}
657
654
658
655
#[cfg(unix)]
659
- fn do_copy_file(+ from: Path, + to: Path) -> bool {
656
+ fn do_copy_file(from: Path, to: Path) -> bool {
660
657
let istream = do as_c_charp(from) |fromp| {
661
658
do as_c_charp(~" rb") |modebuf| {
662
659
libc:: fopen ( fromp, modebuf)
@@ -702,11 +699,11 @@ fn copy_file(+from: Path, +to: Path) -> bool {
702
699
}
703
700
704
701
/// Deletes an existing file
705
- fn remove_file(+ p: Path) -> bool {
702
+ fn remove_file(p: Path) -> bool {
706
703
return unlink(p);
707
704
708
705
#[cfg(windows)]
709
- fn unlink(+ p: Path) -> bool {
706
+ fn unlink(p: Path) -> bool {
710
707
// FIXME (similar to Issue #2006): remove imports when export globs
711
708
// work properly.
712
709
import libc::funcs::extra::kernel32::*;
@@ -718,7 +715,7 @@ fn remove_file(+p: Path) -> bool {
718
715
}
719
716
720
717
#[cfg(unix)]
721
- fn unlink(+ p: Path) -> bool {
718
+ fn unlink(p: Path) -> bool {
722
719
return do as_c_charp(p) |buf| {
723
720
libc::unlink(buf) == (0 as c_int)
724
721
};
0 commit comments