@@ -465,16 +465,16 @@ fn homedir() -> option<Path> {
465
465
}
466
466
467
467
/**
468
- * Returns the path to a temporary directory, if known .
468
+ * Returns the path to a temporary directory.
469
469
*
470
470
* On Unix, returns the value of the 'TMPDIR' environment variable if it is
471
471
* set and non-empty and '/tmp' otherwise.
472
472
*
473
473
* 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 .
476
476
*/
477
- fn tmpdir ( ) -> option < Path > {
477
+ fn tmpdir ( ) -> Path {
478
478
return lookup ( ) ;
479
479
480
480
fn getenv_nonempty ( v : Path ) -> option < Path > {
@@ -490,15 +490,18 @@ fn tmpdir() -> option<Path> {
490
490
}
491
491
492
492
#[ 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")
495
495
}
496
496
497
497
#[ 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 ")
502
505
}
503
506
}
504
507
/// Recursively walk a directory structure
@@ -970,7 +973,7 @@ mod tests {
970
973
971
974
#[ test]
972
975
fn tmpdir ( ) {
973
- option :: iter ( os :: tmpdir ( ) , |s| assert !str:: is_empty ( s ) ) ;
976
+ assert !str:: is_empty ( os :: tmpdir ( ) ) ;
974
977
}
975
978
976
979
// Issue #712
0 commit comments