Skip to content

Commit d2e2d97

Browse files
committed
Merge pull request #3231 from killerswan/modes1
Remove deprecated modes from os.rs
2 parents dbba49f + 77ef394 commit d2e2d97

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::*;
@@ -362,7 +365,7 @@ fn dup2(src: c_int, dst: c_int) -> c_int {
362365
}
363366

364367

365-
fn dll_filename(base: ~str) -> ~str {
368+
fn dll_filename(+base: ~str) -> ~str {
366369
return pre() + base + dll_suffix();
367370

368371
#[cfg(unix)]
@@ -509,11 +512,11 @@ fn tmpdir() -> Path {
509512
}
510513
}
511514
/// 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) {
513516

514517
walk_dir_(p, f);
515518

516-
fn walk_dir_(p: Path, f: fn(Path) -> bool) -> bool {
519+
fn walk_dir_(+p: Path, f: fn(Path) -> bool) -> bool {
517520
let mut keepgoing = true;
518521
do list_dir(p).each |q| {
519522
let path = path::connect(p, q);
@@ -538,14 +541,14 @@ fn walk_dir(p: Path, f: fn(Path) -> bool) {
538541
}
539542

540543
/// Indicates whether a path represents a directory
541-
fn path_is_dir(p: Path) -> bool {
544+
fn path_is_dir(+p: Path) -> bool {
542545
do str::as_c_str(p) |buf| {
543546
rustrt::rust_path_is_dir(buf) != 0 as c_int
544547
}
545548
}
546549

547550
/// Indicates whether a path exists
548-
fn path_exists(p: Path) -> bool {
551+
fn path_exists(+p: Path) -> bool {
549552
do str::as_c_str(p) |buf| {
550553
rustrt::rust_path_exists(buf) != 0 as c_int
551554
}
@@ -563,7 +566,7 @@ fn path_exists(p: Path) -> bool {
563566
// NB: this is here rather than in path because it is a form of environment
564567
// querying; what it does depends on the process working directory, not just
565568
// the input paths.
566-
fn make_absolute(p: Path) -> Path {
569+
fn make_absolute(+p: Path) -> Path {
567570
if path::path_is_absolute(p) {
568571
p
569572
} else {
@@ -573,11 +576,11 @@ fn make_absolute(p: Path) -> Path {
573576

574577

575578
/// 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 {
577580
return mkdir(p, mode);
578581

579582
#[cfg(windows)]
580-
fn mkdir(p: Path, _mode: c_int) -> bool {
583+
fn mkdir(+p: Path, _mode: c_int) -> bool {
581584
// FIXME: remove imports when export globs work properly. #1238
582585
import libc::types::os::arch::extra::*;
583586
import libc::funcs::extra::kernel32::*;
@@ -590,21 +593,21 @@ fn make_dir(p: Path, mode: c_int) -> bool {
590593
}
591594

592595
#[cfg(unix)]
593-
fn mkdir(p: Path, mode: c_int) -> bool {
596+
fn mkdir(+p: Path, mode: c_int) -> bool {
594597
do as_c_charp(p) |c| {
595598
libc::mkdir(c, mode as mode_t) == (0 as c_int)
596599
}
597600
}
598601
}
599602

600603
/// Lists the contents of a directory
601-
fn list_dir(p: Path) -> ~[~str] {
604+
fn list_dir(+p: Path) -> ~[~str] {
602605

603606
#[cfg(unix)]
604-
fn star(p: ~str) -> ~str { p }
607+
fn star(+p: ~str) -> ~str { p }
605608

606609
#[cfg(windows)]
607-
fn star(p: ~str) -> ~str {
610+
fn star(+p: ~str) -> ~str {
608611
let pl = str::len(p);
609612
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
610613
|| p[pl - 1u] as char != path::consts::alt_path_sep) {
@@ -624,7 +627,7 @@ fn list_dir(p: Path) -> ~[~str] {
624627
*
625628
* This version prepends each entry with the directory.
626629
*/
627-
fn list_dir_path(p: Path) -> ~[~str] {
630+
fn list_dir_path(+p: Path) -> ~[~str] {
628631
let mut p = p;
629632
let pl = str::len(p);
630633
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
@@ -635,11 +638,11 @@ fn list_dir_path(p: Path) -> ~[~str] {
635638
}
636639
637640
/// Removes a directory at the specified path
638-
fn remove_dir(p: Path) -> bool {
641+
fn remove_dir(+p: Path) -> bool {
639642
return rmdir(p);
640643
641644
#[cfg(windows)]
642-
fn rmdir(p: Path) -> bool {
645+
fn rmdir(+p: Path) -> bool {
643646
// FIXME: remove imports when export globs work properly. #1238
644647
import libc::funcs::extra::kernel32::*;
645648
import libc::types::os::arch::extra::*;
@@ -650,18 +653,18 @@ fn remove_dir(p: Path) -> bool {
650653
}
651654
652655
#[cfg(unix)]
653-
fn rmdir(p: Path) -> bool {
656+
fn rmdir(+p: Path) -> bool {
654657
return do as_c_charp(p) |buf| {
655658
libc::rmdir(buf) == (0 as c_int)
656659
};
657660
}
658661
}
659662
660-
fn change_dir(p: Path) -> bool {
663+
fn change_dir(+p: Path) -> bool {
661664
return chdir(p);
662665
663666
#[cfg(windows)]
664-
fn chdir(p: Path) -> bool {
667+
fn chdir(+p: Path) -> bool {
665668
// FIXME: remove imports when export globs work properly. #1238
666669
import libc::funcs::extra::kernel32::*;
667670
import libc::types::os::arch::extra::*;
@@ -672,19 +675,19 @@ fn change_dir(p: Path) -> bool {
672675
}
673676
674677
#[cfg(unix)]
675-
fn chdir(p: Path) -> bool {
678+
fn chdir(+p: Path) -> bool {
676679
return do as_c_charp(p) |buf| {
677680
libc::chdir(buf) == (0 as c_int)
678681
};
679682
}
680683
}
681684
682685
/// 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 {
684687
return do_copy_file(from, to);
685688
686689
#[cfg(windows)]
687-
fn do_copy_file(from: Path, to: Path) -> bool {
690+
fn do_copy_file(+from: Path, +to: Path) -> bool {
688691
// FIXME: remove imports when export globs work properly. #1238
689692
import libc::funcs::extra::kernel32::*;
690693
import libc::types::os::arch::extra::*;
@@ -697,7 +700,7 @@ fn copy_file(from: Path, to: Path) -> bool {
697700
}
698701
699702
#[cfg(unix)]
700-
fn do_copy_file(from: Path, to: Path) -> bool {
703+
fn do_copy_file(+from: Path, +to: Path) -> bool {
701704
let istream = do as_c_charp(from) |fromp| {
702705
do as_c_charp(~"rb") |modebuf| {
703706
libc::fopen(fromp, modebuf)
@@ -743,11 +746,11 @@ fn copy_file(from: Path, to: Path) -> bool {
743746
}
744747
745748
/// Deletes an existing file
746-
fn remove_file(p: Path) -> bool {
749+
fn remove_file(+p: Path) -> bool {
747750
return unlink(p);
748751
749752
#[cfg(windows)]
750-
fn unlink(p: Path) -> bool {
753+
fn unlink(+p: Path) -> bool {
751754
// FIXME (similar to Issue #2006): remove imports when export globs
752755
// work properly.
753756
import libc::funcs::extra::kernel32::*;
@@ -759,7 +762,7 @@ fn remove_file(p: Path) -> bool {
759762
}
760763
761764
#[cfg(unix)]
762-
fn unlink(p: Path) -> bool {
765+
fn unlink(+p: Path) -> bool {
763766
return do as_c_charp(p) |buf| {
764767
libc::unlink(buf) == (0 as c_int)
765768
};

0 commit comments

Comments
 (0)