25 lines
462 B
Go
25 lines
462 B
Go
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 {
|
|
return path, err
|
|
}
|
|
return path, nil
|
|
} else {
|
|
// Create a temporary dir
|
|
workdir, err = os.MkdirTemp("", "shoebill")
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return workdir, nil
|
|
}
|
|
}
|
|
|
|
func RemoveWorkdir(path string) (err error) {
|
|
return os.RemoveAll(path)
|
|
}
|