Initial logic is implemented
This commit is contained in:
28
internal/utils/workdir/workdir.go
Normal file
28
internal/utils/workdir/workdir.go
Normal file
@ -0,0 +1,28 @@
|
||||
package workdir
|
||||
|
||||
import "os"
|
||||
|
||||
func CreateWorkdir(path string) (workdir string, err error) {
|
||||
if len(path) > 0 {
|
||||
// Create a dir using the path
|
||||
// It should not be removed after the execution
|
||||
if err := os.Mkdir(path, 0777); err != nil {
|
||||
return "", err
|
||||
}
|
||||
// TODO(@allanger): I've got a feeling that it doesn't have to look that bad
|
||||
workdir = path
|
||||
} else {
|
||||
// Create a temporary dir
|
||||
// It should be removed after the execution
|
||||
workdir, err = os.MkdirTemp("", "giops")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
}
|
||||
return workdir, nil
|
||||
}
|
||||
|
||||
func RemoveWorkdir(path string) (err error) {
|
||||
return os.RemoveAll(path)
|
||||
}
|
Reference in New Issue
Block a user