Skip to content

Commit be59981

Browse files
committed
---
yaml --- r: 46365 b: refs/heads/auto c: c8d8f6c h: refs/heads/master i: 46363: 473141e v: v3
1 parent 2e631b0 commit be59981

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
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: df4273f8742b2305632916091c2af77128a6e4bf
17+
refs/heads/auto: c8d8f6cfec50cad6b35e3b5fc604abc01a26143e

branches/auto/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

branches/auto/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)