shoebill/internal/utils/workdir/workdir.go

25 lines
462 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
}
2024-07-25 13:23:28 +00:00
return path, nil
2023-07-20 09:26:25 +00:00
} 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 {
2024-07-25 13:23:28 +00:00
return "", err
2023-07-20 09:26:25 +00:00
}
2024-07-25 13:23:28 +00:00
return workdir, nil
2023-07-20 09:26:25 +00:00
}
}
func RemoveWorkdir(path string) (err error) {
return os.RemoveAll(path)
}