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