Skip to content

Commit 54ac665

Browse files
Daniel Pattersonbrson
authored andcommitted
---
yaml --- r: 23358 b: refs/heads/master c: 8b8e0c2 h: refs/heads/master v: v3
1 parent 503d2bb commit 54ac665

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9bb2963b7e922a9e8939253bb131eda9f31ca125
2+
refs/heads/master: 8b8e0c2a452a5f408f1c02470b4af1a4b6609dbb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/os.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -465,16 +465,16 @@ fn homedir() -> option<Path> {
465465
}
466466

467467
/**
468-
* Returns the path to a temporary directory, if known.
468+
* Returns the path to a temporary directory.
469469
*
470470
* On Unix, returns the value of the 'TMPDIR' environment variable if it is
471471
* set and non-empty and '/tmp' otherwise.
472472
*
473473
* On Windows, returns the value of, in order, the 'TMP', 'TEMP',
474-
* 'USERPROFILE' environment variable if any are set and not the empty
475-
* string. Otherwise, tmpdir returns option::none.
474+
* 'USERPROFILE' environment variable if any are set and not the empty
475+
* string. Otherwise, tmpdir returns the path to the Windows directory.
476476
*/
477-
fn tmpdir() -> option<Path> {
477+
fn tmpdir() -> Path {
478478
return lookup();
479479

480480
fn getenv_nonempty(v: Path) -> option<Path> {
@@ -490,15 +490,18 @@ fn tmpdir() -> option<Path> {
490490
}
491491

492492
#[cfg(unix)]
493-
fn lookup() -> option<Path> {
494-
option::or(getenv_nonempty(~"TMPDIR"), some(~"/tmp"))
493+
fn lookup() -> Path {
494+
option::get_default(getenv_nonempty(~"TMPDIR"), ~"/tmp")
495495
}
496496

497497
#[cfg(windows)]
498-
fn lookup() -> option<Path> {
499-
option::or(getenv_nonempty(~"TMP"),
500-
option::or(getenv_nonempty(~"TEMP"),
501-
getenv_nonempty(~"USERPROFILE")))
498+
fn lookup() -> Path {
499+
option::get_default(
500+
option::or(getenv_nonempty(~"TMP"),
501+
option::or(getenv_nonempty(~"TEMP"),
502+
option::or(getenv_nonempty(~"USERPROFILE"),
503+
getenv_nonempty(~"WINDIR")))),
504+
~"C:\\Windows")
502505
}
503506
}
504507
/// Recursively walk a directory structure
@@ -970,7 +973,7 @@ mod tests {
970973

971974
#[test]
972975
fn tmpdir() {
973-
option::iter(os::tmpdir(), |s| assert !str::is_empty(s));
976+
assert !str::is_empty(os::tmpdir());
974977
}
975978

976979
// Issue #712

0 commit comments

Comments
 (0)