aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-12-23 13:59:29 +0100
committerDmitry Vyukov <dvyukov@google.com>2015-12-23 13:59:29 +0100
commit1f580dac3d82075b93cc18044501fd01024d5f9a (patch)
treef99f8ae98782ea7d597b7efd9041826d92957294 /csource
parent2fa51b4807c7a250b49d086f8343546587c95f8a (diff)
fileutil: new package
Move some file utilities into a separate package.
Diffstat (limited to 'csource')
-rw-r--r--csource/csource.go15
-rw-r--r--csource/csource_test.go3
2 files changed, 2 insertions, 16 deletions
diff --git a/csource/csource.go b/csource/csource.go
index 03ce4b84c..5caa74af5 100644
--- a/csource/csource.go
+++ b/csource/csource.go
@@ -199,21 +199,6 @@ loop:
return calls, n
}
-// WriteTempFile writes data to a temp file and returns its name.
-func WriteTempFile(data []byte) (string, error) {
- f, err := ioutil.TempFile("", "syz-prog")
- if err != nil {
- return "", fmt.Errorf("failed to create a temp file: %v", err)
- }
- if _, err := f.Write(data); err != nil {
- f.Close()
- os.Remove(f.Name())
- return "", fmt.Errorf("failed to write temp file: %v", err)
- }
- f.Close()
- return f.Name(), nil
-}
-
// Build builds a C/C++ program from source file src
// and returns name of the resulting binary.
func Build(src string) (string, error) {
diff --git a/csource/csource_test.go b/csource/csource_test.go
index b2fbda6dc..388ab0e1a 100644
--- a/csource/csource_test.go
+++ b/csource/csource_test.go
@@ -9,6 +9,7 @@ import (
"testing"
"time"
+ "github.com/google/syzkaller/fileutil"
"github.com/google/syzkaller/prog"
)
@@ -40,7 +41,7 @@ func Test(t *testing.T) {
func testOne(t *testing.T, p *prog.Prog, opts Options) {
src := Write(p, opts)
- srcf, err := WriteTempFile(src)
+ srcf, err := fileutil.WriteTempFile(src)
if err != nil {
t.Fatalf("%v", err)
}