aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/osutil/osutil_unix.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-22 11:09:53 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-22 13:10:55 +0200
commit913d592f973a0155647473eaa032711fe956f8a5 (patch)
tree29b1b2083c00d199cf4d9a30917411d923b49ef4 /pkg/osutil/osutil_unix.go
parentc26ea367cfa790e86800ac025638ad50f95b8287 (diff)
all: more assorted fuchsia support
Diffstat (limited to 'pkg/osutil/osutil_unix.go')
-rw-r--r--pkg/osutil/osutil_unix.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/osutil/osutil_unix.go b/pkg/osutil/osutil_unix.go
index 01eabc15b..27482b99a 100644
--- a/pkg/osutil/osutil_unix.go
+++ b/pkg/osutil/osutil_unix.go
@@ -90,3 +90,23 @@ func LongPipe() (io.ReadCloser, io.WriteCloser, error) {
prolongPipe(r, w)
return r, w, err
}
+
+var wd string
+
+func init() {
+ var err error
+ wd, err = os.Getwd()
+ if err != nil {
+ panic(fmt.Sprintf("failed to get wd: %v", err))
+ }
+}
+
+func Abs(path string) string {
+ if wd1, err := os.Getwd(); err == nil && wd1 != wd {
+ panic("don't mess with wd in a concurrent program")
+ }
+ if path == "" || filepath.IsAbs(path) {
+ return path
+ }
+ return filepath.Join(wd, path)
+}