forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_nix.go
46 lines (39 loc) · 995 Bytes
/
util_nix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
package libkb
import (
"errors"
"fmt"
"os"
)
func canExec(s string) error {
fi, err := os.Stat(s)
if err != nil {
return err
}
mode := fi.Mode()
//
// Only consider non-directories that have at least one +x
// bit set.
//
// TODO: Recheck this on windows!
// See here for lookpath: http://golang.org/src/pkg/os/exec/lp_windows.go
//
// Similar to check from exec.LookPath below
// See here: http://golang.org/src/pkg/os/exec/lp_unix.go
//
if mode.IsDir() {
return fmt.Errorf("Program '%s' is a directory", s)
} else if int(mode)&0111 == 0 {
return fmt.Errorf("Program '%s' isn't executable", s)
} else {
return nil
}
}
func PosixLineEndings(arg string) string {
return arg
}
func AppDataDir() (string, error) {
return "", errors.New("unsupported: AppDataDir")
}