shoebill/internal/utils/workdir/workdir.go

27 lines
544 B
Go
Raw Normal View History

2023-07-20 09:26:25 +00:00
package workdir
import "os"
func CreateWorkdir(path string) (workdir string, err error) {
if len(path) > 0 {
// Create a dir using the path
if err := os.Mkdir(path, 0777); err != nil {
2023-10-11 12:14:20 +00:00
return path, err
2023-07-20 09:26:25 +00:00
}
// TODO(@allanger): I've got a feeling that it doesn't have to look that bad
workdir = path
} else {
// Create a temporary dir
2023-08-02 15:00:34 +00:00
workdir, err = os.MkdirTemp("", "shoebill")
2023-07-20 09:26:25 +00:00
if err != nil {
2023-10-11 12:14:20 +00:00
return workdir, err
2023-07-20 09:26:25 +00:00
}
}
return workdir, nil
}
func RemoveWorkdir(path string) (err error) {
return os.RemoveAll(path)
}