Add --restrict-library option
This commit is contained in:
parent
c0dd5445f9
commit
6c70ef3ffb
3 changed files with 31 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
0.1.3:
|
||||
- Allow keybindings to be configured
|
||||
- Add --fd option
|
||||
- Add --fd and --restrict-library options
|
||||
|
||||
0.1.2:
|
||||
- Allow audio buffer size to be configured
|
||||
|
|
10
gui.go
10
gui.go
|
@ -92,6 +92,16 @@ func browseFolder(browse string) {
|
|||
mainBufferAutoFocus = ""
|
||||
return
|
||||
}
|
||||
if !strings.HasPrefix(browse, restrictLibrary) {
|
||||
statusText = "failed to browse folder: permission denied"
|
||||
go func() {
|
||||
time.Sleep(5 * time.Second)
|
||||
statusText = ""
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
}()
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
return
|
||||
}
|
||||
|
||||
placeCursorAtTop := mainBufferCursor == 0
|
||||
mainBufferFiles = scanFolder(browse)
|
||||
|
|
26
main.go
26
main.go
|
@ -34,6 +34,7 @@ var (
|
|||
cpuProfile string
|
||||
streamFdInt int
|
||||
streamFd *os.File
|
||||
restrictLibrary string
|
||||
|
||||
done = make(chan bool)
|
||||
)
|
||||
|
@ -48,6 +49,7 @@ func main() {
|
|||
flag.StringVar(&configPath, "config", "", "path to configuration file")
|
||||
flag.BoolVar(&printVersionInfo, "version", false, "print version information and exit")
|
||||
flag.IntVar(&streamFdInt, "fd", -1, "stream audio to file descriptor")
|
||||
flag.StringVar(&restrictLibrary, "restrict-library", "", "restrict library to path")
|
||||
flag.DurationVar(&bufferSize, "buffer-size", defaultBufferSize, "audio buffer size")
|
||||
flag.StringVar(&debugAddress, "debug-address", "", "address to serve debug info")
|
||||
flag.StringVar(&cpuProfile, "cpu-profile", "", "path to save CPU profiling")
|
||||
|
@ -58,6 +60,14 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
if restrictLibrary != "" {
|
||||
var err error
|
||||
restrictLibrary, err = filepath.Abs(restrictLibrary)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to restrict library to %s: %s", restrictLibrary, err)
|
||||
}
|
||||
}
|
||||
|
||||
if debugAddress != "" {
|
||||
go func() {
|
||||
log.Fatal(http.ListenAndServe(debugAddress, nil))
|
||||
|
@ -113,14 +123,18 @@ func main() {
|
|||
|
||||
startPath := strings.Join(flag.Args(), " ")
|
||||
if startPath == "" {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil || wd == "" {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err == nil && homeDir != "" {
|
||||
startPath = homeDir
|
||||
if restrictLibrary == "" {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil || wd == "" {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err == nil && homeDir != "" {
|
||||
startPath = homeDir
|
||||
}
|
||||
} else {
|
||||
startPath = wd
|
||||
}
|
||||
} else {
|
||||
startPath = wd
|
||||
startPath = restrictLibrary
|
||||
}
|
||||
}
|
||||
if startPath == "" {
|
||||
|
|
Loading…
Reference in a new issue