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:: * ;
@@ -362,7 +365,7 @@ fn dup2(src: c_int, dst: c_int) -> c_int {
362
365
}
363
366
364
367
365
- fn dll_filename ( base : ~str ) -> ~str {
368
+ fn dll_filename ( + base : ~str ) -> ~str {
366
369
return pre ( ) + base + dll_suffix ( ) ;
367
370
368
371
#[ cfg( unix) ]
@@ -509,11 +512,11 @@ fn tmpdir() -> Path {
509
512
}
510
513
}
511
514
/// Recursively walk a directory structure
512
- fn walk_dir( p : Path , f : fn ( Path ) -> bool ) {
515
+ fn walk_dir( + p : Path , f : fn ( Path ) -> bool ) {
513
516
514
517
walk_dir_ ( p, f) ;
515
518
516
- fn walk_dir_ ( p : Path , f : fn ( Path ) -> bool ) -> bool {
519
+ fn walk_dir_ ( + p : Path , f : fn ( Path ) -> bool ) -> bool {
517
520
let mut keepgoing = true ;
518
521
do list_dir( p) . each |q| {
519
522
let path = path:: connect ( p, q) ;
@@ -538,14 +541,14 @@ fn walk_dir(p: Path, f: fn(Path) -> bool) {
538
541
}
539
542
540
543
/// Indicates whether a path represents a directory
541
- fn path_is_dir ( p : Path ) -> bool {
544
+ fn path_is_dir ( + p : Path ) -> bool {
542
545
do str:: as_c_str ( p) |buf| {
543
546
rustrt:: rust_path_is_dir ( buf) != 0 as c_int
544
547
}
545
548
}
546
549
547
550
/// Indicates whether a path exists
548
- fn path_exists ( p : Path ) -> bool {
551
+ fn path_exists ( + p : Path ) -> bool {
549
552
do str:: as_c_str ( p) |buf| {
550
553
rustrt:: rust_path_exists ( buf) != 0 as c_int
551
554
}
@@ -563,7 +566,7 @@ fn path_exists(p: Path) -> bool {
563
566
// NB: this is here rather than in path because it is a form of environment
564
567
// querying; what it does depends on the process working directory, not just
565
568
// the input paths.
566
- fn make_absolute ( p : Path ) -> Path {
569
+ fn make_absolute ( + p : Path ) -> Path {
567
570
if path:: path_is_absolute ( p) {
568
571
p
569
572
} else {
@@ -573,11 +576,11 @@ fn make_absolute(p: Path) -> Path {
573
576
574
577
575
578
/// Creates a directory at the specified path
576
- fn make_dir ( p : Path , mode : c_int ) -> bool {
579
+ fn make_dir ( + p : Path , mode : c_int ) -> bool {
577
580
return mkdir ( p, mode) ;
578
581
579
582
#[ cfg( windows) ]
580
- fn mkdir ( p : Path , _mode : c_int ) -> bool {
583
+ fn mkdir ( + p : Path , _mode : c_int ) -> bool {
581
584
// FIXME: remove imports when export globs work properly. #1238
582
585
import libc:: types:: os:: arch:: extra:: * ;
583
586
import libc:: funcs:: extra:: kernel32:: * ;
@@ -590,21 +593,21 @@ fn make_dir(p: Path, mode: c_int) -> bool {
590
593
}
591
594
592
595
#[ cfg( unix) ]
593
- fn mkdir ( p : Path , mode : c_int ) -> bool {
596
+ fn mkdir ( + p : Path , mode : c_int ) -> bool {
594
597
do as_c_charp ( p) |c| {
595
598
libc:: mkdir ( c, mode as mode_t ) == ( 0 as c_int )
596
599
}
597
600
}
598
601
}
599
602
600
603
/// Lists the contents of a directory
601
- fn list_dir( p : Path ) -> ~[ ~str ] {
604
+ fn list_dir( + p : Path ) -> ~[ ~str ] {
602
605
603
606
#[ cfg( unix) ]
604
- fn star ( p : ~str ) -> ~str { p }
607
+ fn star ( + p : ~str ) -> ~str { p }
605
608
606
609
#[ cfg( windows) ]
607
- fn star( p : ~str ) -> ~str {
610
+ fn star( + p : ~str ) -> ~str {
608
611
let pl = str:: len ( p) ;
609
612
if pl == 0 u || ( p[ pl - 1 u] as char != path:: consts:: path_sep
610
613
|| p[ pl - 1 u] as char != path:: consts:: alt_path_sep) {
@@ -624,7 +627,7 @@ fn list_dir(p: Path) -> ~[~str] {
624
627
*
625
628
* This version prepends each entry with the directory.
626
629
*/
627
- fn list_dir_path(p: Path) -> ~[~str] {
630
+ fn list_dir_path(+ p: Path) -> ~[~str] {
628
631
let mut p = p;
629
632
let pl = str::len(p);
630
633
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
@@ -635,11 +638,11 @@ fn list_dir_path(p: Path) -> ~[~str] {
635
638
}
636
639
637
640
/// Removes a directory at the specified path
638
- fn remove_dir(p: Path) -> bool {
641
+ fn remove_dir(+ p: Path) -> bool {
639
642
return rmdir(p);
640
643
641
644
#[cfg(windows)]
642
- fn rmdir(p: Path) -> bool {
645
+ fn rmdir(+ p: Path) -> bool {
643
646
// FIXME: remove imports when export globs work properly. #1238
644
647
import libc::funcs::extra::kernel32::*;
645
648
import libc::types::os::arch::extra::*;
@@ -650,18 +653,18 @@ fn remove_dir(p: Path) -> bool {
650
653
}
651
654
652
655
#[cfg(unix)]
653
- fn rmdir(p: Path) -> bool {
656
+ fn rmdir(+ p: Path) -> bool {
654
657
return do as_c_charp(p) |buf| {
655
658
libc::rmdir(buf) == (0 as c_int)
656
659
};
657
660
}
658
661
}
659
662
660
- fn change_dir(p: Path) -> bool {
663
+ fn change_dir(+ p: Path) -> bool {
661
664
return chdir(p);
662
665
663
666
#[cfg(windows)]
664
- fn chdir(p: Path) -> bool {
667
+ fn chdir(+ p: Path) -> bool {
665
668
// FIXME: remove imports when export globs work properly. #1238
666
669
import libc::funcs::extra::kernel32::*;
667
670
import libc::types::os::arch::extra::*;
@@ -672,19 +675,19 @@ fn change_dir(p: Path) -> bool {
672
675
}
673
676
674
677
#[cfg(unix)]
675
- fn chdir(p: Path) -> bool {
678
+ fn chdir(+ p: Path) -> bool {
676
679
return do as_c_charp(p) |buf| {
677
680
libc::chdir(buf) == (0 as c_int)
678
681
};
679
682
}
680
683
}
681
684
682
685
/// Copies a file from one location to another
683
- fn copy_file(from: Path, to: Path) -> bool {
686
+ fn copy_file(+ from: Path, + to: Path) -> bool {
684
687
return do_copy_file(from, to);
685
688
686
689
#[cfg(windows)]
687
- fn do_copy_file(from: Path, to: Path) -> bool {
690
+ fn do_copy_file(+ from: Path, + to: Path) -> bool {
688
691
// FIXME: remove imports when export globs work properly. #1238
689
692
import libc::funcs::extra::kernel32::*;
690
693
import libc::types::os::arch::extra::*;
@@ -697,7 +700,7 @@ fn copy_file(from: Path, to: Path) -> bool {
697
700
}
698
701
699
702
#[cfg(unix)]
700
- fn do_copy_file(from: Path, to: Path) -> bool {
703
+ fn do_copy_file(+ from: Path, + to: Path) -> bool {
701
704
let istream = do as_c_charp(from) |fromp| {
702
705
do as_c_charp(~" rb") |modebuf| {
703
706
libc:: fopen ( fromp, modebuf)
@@ -743,11 +746,11 @@ fn copy_file(from: Path, to: Path) -> bool {
743
746
}
744
747
745
748
/// Deletes an existing file
746
- fn remove_file(p: Path) -> bool {
749
+ fn remove_file(+ p: Path) -> bool {
747
750
return unlink(p);
748
751
749
752
#[cfg(windows)]
750
- fn unlink(p: Path) -> bool {
753
+ fn unlink(+ p: Path) -> bool {
751
754
// FIXME (similar to Issue #2006): remove imports when export globs
752
755
// work properly.
753
756
import libc::funcs::extra::kernel32::*;
@@ -759,7 +762,7 @@ fn remove_file(p: Path) -> bool {
759
762
}
760
763
761
764
#[cfg(unix)]
762
- fn unlink(p: Path) -> bool {
765
+ fn unlink(+ p: Path) -> bool {
763
766
return do as_c_charp(p) |buf| {
764
767
libc::unlink(buf) == (0 as c_int)
765
768
};
0 commit comments