Skip to content

Commit feb897d

Browse files
committed
---
yaml --- r: 44582 b: refs/heads/master c: c8d8f6c h: refs/heads/master v: v3
1 parent 844d7e7 commit feb897d

File tree

8 files changed

+205
-186
lines changed

8 files changed

+205
-186
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: df4273f8742b2305632916091c2af77128a6e4bf
2+
refs/heads/master: c8d8f6cfec50cad6b35e3b5fc604abc01a26143e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/libcore/os.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,17 +565,13 @@ pub fn path_exists(p: &Path) -> bool {
565565
*
566566
* If the given path is relative, return it prepended with the current working
567567
* directory. If the given path is already an absolute path, return it
568-
* as is.
568+
* as is. This is a shortcut for calling os::getcwd().unsafe_join(p)
569569
*/
570570
// NB: this is here rather than in path because it is a form of environment
571571
// querying; what it does depends on the process working directory, not just
572572
// the input paths.
573573
pub fn make_absolute(p: &Path) -> Path {
574-
if p.is_absolute {
575-
copy *p
576-
} else {
577-
getcwd().push_many(p.components)
578-
}
574+
getcwd().unsafe_join(p)
579575
}
580576

581577

trunk/src/libcore/path.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ pub trait GenericPath {
6464
pure fn push_many((&[~str])) -> Self;
6565
pure fn pop() -> Self;
6666

67+
pure fn unsafe_join((&Self)) -> Self;
68+
6769
pure fn normalize() -> Self;
6870
}
6971

@@ -485,6 +487,15 @@ impl GenericPath for PosixPath {
485487
self.push_many(other.components)
486488
}
487489

490+
pure fn unsafe_join(other: &PosixPath) -> PosixPath {
491+
if other.is_absolute {
492+
PosixPath { is_absolute: true,
493+
components: copy other.components }
494+
} else {
495+
self.push_rel(other)
496+
}
497+
}
498+
488499
pure fn push_many(cs: &[~str]) -> PosixPath {
489500
let mut v = copy self.components;
490501
for cs.each |e| {
@@ -685,6 +696,25 @@ impl GenericPath for WindowsPath {
685696
self.push_many(other.components)
686697
}
687698

699+
pure fn unsafe_join(other: &WindowsPath) -> WindowsPath {
700+
if !other.is_absolute {
701+
self.push_rel(other)
702+
} else {
703+
WindowsPath {
704+
host: match other.host {
705+
None => copy self.host,
706+
Some(copy x) => Some(x)
707+
},
708+
device: match other.device {
709+
None => copy self.device,
710+
Some(copy x) => Some(x)
711+
},
712+
is_absolute: true,
713+
components: copy other.components
714+
}
715+
}
716+
}
717+
688718
pure fn push_many(cs: &[~str]) -> WindowsPath {
689719
let mut v = copy self.components;
690720
for cs.each |e| {

0 commit comments

Comments
 (0)