Skip to content

Commit 77ef394

Browse files
committed
Remove deprecated modes from os.rs
1 parent 08441fc commit 77ef394

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

src/libcore/os.rs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
* to write OS-ignorant code by default.
1717
*/
1818

19+
#[forbid(deprecated_mode)];
20+
#[forbid(deprecated_pattern)];
21+
1922
import libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t,
2023
mode_t, pid_t, FILE};
2124
import libc::{close, fclose};
@@ -53,7 +56,7 @@ extern mod rustrt {
5356

5457
const tmpbuf_sz : uint = 1000u;
5558

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 {
5760
str::as_c_str(s, |b| f(b as *c_char))
5861
}
5962

@@ -103,19 +106,19 @@ mod win32 {
103106
return res;
104107
}
105108

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 {
107110
let mut t = str::to_utf16(s);
108111
// Null terminate before passing on.
109112
t += ~[0u16];
110113
vec::as_buf(t, |buf, _len| f(buf))
111114
}
112115
}
113116

114-
fn getenv(n: ~str) -> option<~str> {
117+
fn getenv(+n: ~str) -> option<~str> {
115118
global_env::getenv(n)
116119
}
117120

118-
fn setenv(n: ~str, v: ~str) {
121+
fn setenv(+n: ~str, +v: ~str) {
119122
global_env::setenv(n, v)
120123
}
121124

@@ -140,14 +143,14 @@ mod global_env {
140143
MsgEnv(comm::Chan<~[(~str,~str)]>)
141144
}
142145

143-
fn getenv(n: ~str) -> option<~str> {
146+
fn getenv(+n: ~str) -> option<~str> {
144147
let env_ch = get_global_env_chan();
145148
let po = comm::port();
146149
comm::send(env_ch, MsgGetEnv(n, comm::chan(po)));
147150
comm::recv(po)
148151
}
149152

150-
fn setenv(n: ~str, v: ~str) {
153+
fn setenv(+n: ~str, +v: ~str) {
151154
let env_ch = get_global_env_chan();
152155
let po = comm::port();
153156
comm::send(env_ch, MsgSetEnv(n, v, comm::chan(po)));
@@ -209,7 +212,7 @@ mod global_env {
209212
}
210213

211214
#[cfg(unix)]
212-
fn getenv(n: ~str) -> option<~str> {
215+
fn getenv(+n: ~str) -> option<~str> {
213216
unsafe {
214217
let s = str::as_c_str(n, libc::getenv);
215218
return if unsafe::reinterpret_cast(s) == 0 {
@@ -222,7 +225,7 @@ mod global_env {
222225
}
223226

224227
#[cfg(windows)]
225-
fn getenv(n: ~str) -> option<~str> {
228+
fn getenv(+n: ~str) -> option<~str> {
226229
import libc::types::os::arch::extra::*;
227230
import libc::funcs::extra::kernel32::*;
228231
import win32::*;
@@ -235,7 +238,7 @@ mod global_env {
235238

236239

237240
#[cfg(unix)]
238-
fn setenv(n: ~str, v: ~str) {
241+
fn setenv(+n: ~str, +v: ~str) {
239242

240243
// FIXME: remove this when export globs work properly. #1238
241244
import libc::funcs::posix01::unistd::setenv;
@@ -248,7 +251,7 @@ mod global_env {
248251

249252

250253
#[cfg(windows)]
251-
fn setenv(n: ~str, v: ~str) {
254+
fn setenv(+n: ~str, +v: ~str) {
252255
// FIXME: remove imports when export globs work properly. #1238
253256
import libc::funcs::extra::kernel32::*;
254257
import win32::*;
@@ -358,7 +361,7 @@ fn pipe() -> {in: c_int, out: c_int} {
358361
}
359362

360363

361-
fn dll_filename(base: ~str) -> ~str {
364+
fn dll_filename(+base: ~str) -> ~str {
362365
return pre() + base + dll_suffix();
363366

364367
#[cfg(unix)]
@@ -465,11 +468,11 @@ fn homedir() -> option<Path> {
465468
}
466469

467470
/// 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) {
469472

470473
walk_dir_(p, f);
471474

472-
fn walk_dir_(p: Path, f: fn(Path) -> bool) -> bool {
475+
fn walk_dir_(+p: Path, f: fn(Path) -> bool) -> bool {
473476
let mut keepgoing = true;
474477
do list_dir(p).each |q| {
475478
let path = path::connect(p, q);
@@ -494,14 +497,14 @@ fn walk_dir(p: Path, f: fn(Path) -> bool) {
494497
}
495498

496499
/// Indicates whether a path represents a directory
497-
fn path_is_dir(p: Path) -> bool {
500+
fn path_is_dir(+p: Path) -> bool {
498501
do str::as_c_str(p) |buf| {
499502
rustrt::rust_path_is_dir(buf) != 0 as c_int
500503
}
501504
}
502505

503506
/// Indicates whether a path exists
504-
fn path_exists(p: Path) -> bool {
507+
fn path_exists(+p: Path) -> bool {
505508
do str::as_c_str(p) |buf| {
506509
rustrt::rust_path_exists(buf) != 0 as c_int
507510
}
@@ -519,7 +522,7 @@ fn path_exists(p: Path) -> bool {
519522
// NB: this is here rather than in path because it is a form of environment
520523
// querying; what it does depends on the process working directory, not just
521524
// the input paths.
522-
fn make_absolute(p: Path) -> Path {
525+
fn make_absolute(+p: Path) -> Path {
523526
if path::path_is_absolute(p) {
524527
p
525528
} else {
@@ -529,11 +532,11 @@ fn make_absolute(p: Path) -> Path {
529532

530533

531534
/// 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 {
533536
return mkdir(p, mode);
534537

535538
#[cfg(windows)]
536-
fn mkdir(p: Path, _mode: c_int) -> bool {
539+
fn mkdir(+p: Path, _mode: c_int) -> bool {
537540
// FIXME: remove imports when export globs work properly. #1238
538541
import libc::types::os::arch::extra::*;
539542
import libc::funcs::extra::kernel32::*;
@@ -546,21 +549,21 @@ fn make_dir(p: Path, mode: c_int) -> bool {
546549
}
547550

548551
#[cfg(unix)]
549-
fn mkdir(p: Path, mode: c_int) -> bool {
552+
fn mkdir(+p: Path, mode: c_int) -> bool {
550553
do as_c_charp(p) |c| {
551554
libc::mkdir(c, mode as mode_t) == (0 as c_int)
552555
}
553556
}
554557
}
555558

556559
/// Lists the contents of a directory
557-
fn list_dir(p: Path) -> ~[~str] {
560+
fn list_dir(+p: Path) -> ~[~str] {
558561

559562
#[cfg(unix)]
560-
fn star(p: ~str) -> ~str { p }
563+
fn star(+p: ~str) -> ~str { p }
561564

562565
#[cfg(windows)]
563-
fn star(p: ~str) -> ~str {
566+
fn star(+p: ~str) -> ~str {
564567
let pl = str::len(p);
565568
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
566569
|| p[pl - 1u] as char != path::consts::alt_path_sep) {
@@ -580,7 +583,7 @@ fn list_dir(p: Path) -> ~[~str] {
580583
*
581584
* This version prepends each entry with the directory.
582585
*/
583-
fn list_dir_path(p: Path) -> ~[~str] {
586+
fn list_dir_path(+p: Path) -> ~[~str] {
584587
let mut p = p;
585588
let pl = str::len(p);
586589
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
@@ -591,11 +594,11 @@ fn list_dir_path(p: Path) -> ~[~str] {
591594
}
592595
593596
/// Removes a directory at the specified path
594-
fn remove_dir(p: Path) -> bool {
597+
fn remove_dir(+p: Path) -> bool {
595598
return rmdir(p);
596599
597600
#[cfg(windows)]
598-
fn rmdir(p: Path) -> bool {
601+
fn rmdir(+p: Path) -> bool {
599602
// FIXME: remove imports when export globs work properly. #1238
600603
import libc::funcs::extra::kernel32::*;
601604
import libc::types::os::arch::extra::*;
@@ -606,18 +609,18 @@ fn remove_dir(p: Path) -> bool {
606609
}
607610
608611
#[cfg(unix)]
609-
fn rmdir(p: Path) -> bool {
612+
fn rmdir(+p: Path) -> bool {
610613
return do as_c_charp(p) |buf| {
611614
libc::rmdir(buf) == (0 as c_int)
612615
};
613616
}
614617
}
615618
616-
fn change_dir(p: Path) -> bool {
619+
fn change_dir(+p: Path) -> bool {
617620
return chdir(p);
618621
619622
#[cfg(windows)]
620-
fn chdir(p: Path) -> bool {
623+
fn chdir(+p: Path) -> bool {
621624
// FIXME: remove imports when export globs work properly. #1238
622625
import libc::funcs::extra::kernel32::*;
623626
import libc::types::os::arch::extra::*;
@@ -628,19 +631,19 @@ fn change_dir(p: Path) -> bool {
628631
}
629632
630633
#[cfg(unix)]
631-
fn chdir(p: Path) -> bool {
634+
fn chdir(+p: Path) -> bool {
632635
return do as_c_charp(p) |buf| {
633636
libc::chdir(buf) == (0 as c_int)
634637
};
635638
}
636639
}
637640
638641
/// 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 {
640643
return do_copy_file(from, to);
641644
642645
#[cfg(windows)]
643-
fn do_copy_file(from: Path, to: Path) -> bool {
646+
fn do_copy_file(+from: Path, +to: Path) -> bool {
644647
// FIXME: remove imports when export globs work properly. #1238
645648
import libc::funcs::extra::kernel32::*;
646649
import libc::types::os::arch::extra::*;
@@ -653,7 +656,7 @@ fn copy_file(from: Path, to: Path) -> bool {
653656
}
654657
655658
#[cfg(unix)]
656-
fn do_copy_file(from: Path, to: Path) -> bool {
659+
fn do_copy_file(+from: Path, +to: Path) -> bool {
657660
let istream = do as_c_charp(from) |fromp| {
658661
do as_c_charp(~"rb") |modebuf| {
659662
libc::fopen(fromp, modebuf)
@@ -699,11 +702,11 @@ fn copy_file(from: Path, to: Path) -> bool {
699702
}
700703
701704
/// Deletes an existing file
702-
fn remove_file(p: Path) -> bool {
705+
fn remove_file(+p: Path) -> bool {
703706
return unlink(p);
704707
705708
#[cfg(windows)]
706-
fn unlink(p: Path) -> bool {
709+
fn unlink(+p: Path) -> bool {
707710
// FIXME (similar to Issue #2006): remove imports when export globs
708711
// work properly.
709712
import libc::funcs::extra::kernel32::*;
@@ -715,7 +718,7 @@ fn remove_file(p: Path) -> bool {
715718
}
716719
717720
#[cfg(unix)]
718-
fn unlink(p: Path) -> bool {
721+
fn unlink(+p: Path) -> bool {
719722
return do as_c_charp(p) |buf| {
720723
libc::unlink(buf) == (0 as c_int)
721724
};

0 commit comments

Comments
 (0)