Browse Source

Add Tempdir

pull/1842/head
Jae Kwon 8 years ago
parent
commit
6b4160f2a5
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      os.go

+ 13
- 0
os.go View File

@ -113,6 +113,19 @@ func Tempfile(prefix string) (*os.File, string) {
return file, file.Name()
}
func Tempdir(prefix string) (*os.File, string) {
tempDir := os.TempDir() + "/" + prefix + RandStr(12)
err := EnsureDir(tempDir, 0700)
if err != nil {
panic(Fmt("Error creating temp dir: %v", err))
}
dir, err := os.Open(tempDir)
if err != nil {
panic(Fmt("Error opening temp dir: %v", err))
}
return dir, tempDir
}
//--------------------------------------------------------------------------------
func Prompt(prompt string, defaultValue string) (string, error) {


Loading…
Cancel
Save