aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-24 10:04:02 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-25 15:19:06 +0200
commitdcf893f99cdcead3d82e987953341caa030b30f9 (patch)
tree7a5303ffd6208b27d39a1bdb631e3513e828ce2d
parent4a0022152693f8c10ef0b894bcc275fb19b5b5ba (diff)
pkg/osutil: windows port
-rw-r--r--pkg/osutil/osutil.go28
-rw-r--r--pkg/osutil/osutil_fuchsia.go8
-rw-r--r--pkg/osutil/osutil_unix.go20
-rw-r--r--pkg/osutil/osutil_windows.go7
4 files changed, 35 insertions, 28 deletions
diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go
index 79cd455c2..d98e91e19 100644
--- a/pkg/osutil/osutil.go
+++ b/pkg/osutil/osutil.go
@@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"time"
)
@@ -145,3 +146,30 @@ func ListDir(dir string) ([]string, error) {
defer f.Close()
return f.Readdirnames(-1)
}
+
+var wd string
+
+func init() {
+ if runtime.GOOS == "fuchsia" {
+ return
+ }
+ 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 runtime.GOOS == "fuchsia" {
+ // Getwd/Abs are not supported on fuchsia. Let's hope for best.
+ return path
+ }
+ 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)
+}
diff --git a/pkg/osutil/osutil_fuchsia.go b/pkg/osutil/osutil_fuchsia.go
index 75cdad843..db7b041d6 100644
--- a/pkg/osutil/osutil_fuchsia.go
+++ b/pkg/osutil/osutil_fuchsia.go
@@ -7,11 +7,3 @@ package osutil
func HandleInterrupts(shutdown chan struct{}) {
}
-
-func Abs(path string) string {
- // Getwd is not implemented. Let's hope for best.
- if path == "" {
- return ""
- }
- return "./" + path
-}
diff --git a/pkg/osutil/osutil_unix.go b/pkg/osutil/osutil_unix.go
index 27482b99a..01eabc15b 100644
--- a/pkg/osutil/osutil_unix.go
+++ b/pkg/osutil/osutil_unix.go
@@ -90,23 +90,3 @@ 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)
-}
diff --git a/pkg/osutil/osutil_windows.go b/pkg/osutil/osutil_windows.go
new file mode 100644
index 000000000..861ae8fb3
--- /dev/null
+++ b/pkg/osutil/osutil_windows.go
@@ -0,0 +1,7 @@
+// Copyright 2017 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package osutil
+
+func HandleInterrupts(shutdown chan struct{}) {
+}