Skip to content

Commit 936e177

Browse files
committed
---
yaml --- r: 44156 b: refs/heads/snap-stage3 c: c8d8f6c h: refs/heads/master v: v3
1 parent e14fcc4 commit 936e177

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,7 +1,7 @@
11
---
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: df4273f8742b2305632916091c2af77128a6e4bf
4+
refs/heads/snap-stage3: c8d8f6cfec50cad6b35e3b5fc604abc01a26143e
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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/snap-stage3/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)