This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
func TempFile(dir, prefix string) (*os.File, error) {
// Assume that probability of suffix collision is negligible
suffix := strconv.FormatInt(time.Now().UnixNano()+int64(os.Getpid()), 16)
func TempFile(dir, prefix string) (*os.File, error) {
// Assume that probability of suffix collision is negligible
suffix := strconv.FormatInt(time.Now().UnixNano()+int64(os.Getpid()), 16)
func (ctx *Ctx) NewTmpFile() (*os.File, error) {
jobsPath := filepath.Join(ctx.Spool, "tmp")
func (ctx *Ctx) NewTmpFile() (*os.File, error) {
jobsPath := filepath.Join(ctx.Spool, "tmp")
- if _, err := os.Stat(jobsPath); err != nil {
- if !os.IsNotExist(err) {
- return nil, err
- }
- if err := os.MkdirAll(jobsPath, os.FileMode(0777)); err != nil {
- return nil, err
- }
+ if err := ensureDir(jobsPath); err != nil {
+ return nil, err
- if _, err = os.Stat(dir); err != nil {
- if !os.IsNotExist(err) {
- return err
- }
- if err = os.MkdirAll(dir, os.FileMode(0777)); err != nil {
- return err
- }
+ if err = ensureDir(dir); err != nil {
+ return err