Commit 59c20b69 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use ioutil.TempDir().

parent c9b89bad
...@@ -5,31 +5,22 @@ package fuse ...@@ -5,31 +5,22 @@ package fuse
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"rand"
"os" "os"
"time"
"fmt" "fmt"
"path/filepath"
"math" "math"
"regexp" "regexp"
"syscall" "syscall"
"unsafe" "unsafe"
"io/ioutil"
) )
// Make a temporary directory securely. // Make a temporary directory securely.
//
// Should move somewhere into Go library?
func MakeTempDir() string { func MakeTempDir() string {
source := rand.NewSource(time.Nanoseconds()) nm, err := ioutil.TempDir("", "go-fuse");
number := source.Int63() & 0xffff
name := fmt.Sprintf("tmp%d", number)
fullName := filepath.Join(os.TempDir(), name)
err := os.Mkdir(fullName, 0700)
if err != nil { if err != nil {
panic("Mkdir() should always succeed: " + fullName) panic("TempDir() failed: " + err.String())
} }
return fullName return nm
} }
// Convert os.Error back to Errno based errors. // Convert os.Error back to Errno based errors.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment