Added a quick and dirty file open check
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
12
util/file.go
12
util/file.go
@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
@ -8,3 +9,14 @@ import (
|
||||
func FilenameWithoutExtension(filename string) string {
|
||||
return strings.TrimSuffix(filename, path.Ext(filename))
|
||||
}
|
||||
|
||||
func IsFileLocked(filepath string) bool {
|
||||
cmd := exec.Command("/usr/bin/lsof", filepath)
|
||||
stdout, _ := cmd.Output()
|
||||
|
||||
if strings.Contains(string(stdout), filepath) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user