This commit is contained in:
parent
28a4f4121e
commit
98191fd098
7 changed files with 112 additions and 11 deletions
|
@ -25,6 +25,11 @@ var (
|
|||
false,
|
||||
"Also start the local debugging server",
|
||||
)
|
||||
FlagLogFile *string = flag.String(
|
||||
"logfile",
|
||||
"/var/log/linstrom/logs",
|
||||
"Set the target logging file. Linstrom auto-rotates these. If it can't be created, it will be ignored",
|
||||
)
|
||||
)
|
||||
|
||||
func flagUsage() {
|
||||
|
@ -50,5 +55,5 @@ func flagUsage() {
|
|||
}
|
||||
|
||||
func init() {
|
||||
flag.Usage = flagUsage
|
||||
// flag.Usage = flagUsage
|
||||
}
|
||||
|
|
11
shared/isWritable.go
Normal file
11
shared/isWritable.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package shared
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// Copied from https://stackoverflow.com/a/20026945 and https://stackoverflow.com/a/49148866
|
||||
func IsWritable(path string) bool {
|
||||
return unix.Access(path, unix.W_OK) == nil
|
||||
}
|
23
shared/isWritable_windows.go
Normal file
23
shared/isWritable_windows.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package shared
|
||||
|
||||
import "os"
|
||||
|
||||
// Copied from https://stackoverflow.com/a/20026945 and https://stackoverflow.com/a/49148866
|
||||
func IsWritable(path string) bool {
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
err = nil
|
||||
if !info.IsDir() {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if the user bit is enabled in file permission
|
||||
if info.Mode().Perm()&(1<<(uint(7))) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue