adept/util/file.go

23 lines
384 B
Go
Raw Permalink Normal View History

package util
import (
"os/exec"
"path"
"strings"
)
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
}