// IsExecutable checks if the given path points to an executable file by
// checking the executable bit. Inspired by os.exec.LookPath()
196500
func IsExecutable(path string) bool {
	d, err := os.Stat(path)
	if err == nil {
		m := d.Mode()
		return !m.IsDir() && m&0111 != 0
	}
	return false
}
191850
func IsExecutable(filename string) bool {
	info, err := os.Stat(filename)
	return err == nil && info.Mode().IsRegular() && (info.Mode()&0111) != 0
}
535931
func IsSubpath(basepath, maybeSubpath string) bool {
	rel, err := filepath.Rel(basepath, maybeSubpath)
	if err != nil {
		return false
	}
	if strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
		// not a subpath if "../" has to be used for the relative path
		return false
	}
	return true
}
834590
func IsFile(path string) bool {
	src, err := os.Stat(path)
	if os.IsNotExist(err) {
		return false
	}
	return !src.IsDir()
}
383713
func HasExtension(filename string, extensions map[string]bool) bool {
	var ext string
	if e := filepath.Ext(filename); strings.HasPrefix(e, ".") {
		ext = e[1:]
	} else {
		return false
	}

	// Case-insensitive lookup.
	// Optimistically assume a short ASCII extension and be
	// allocation-free in that case.
	var buf [10]byte
	lower := buf[:0]
	const utf8RuneSelf = 0x80 // from utf8 package, but not importing it.
	for i := 0; i < len(ext); i++ {
		c := ext[i]
		if c >= utf8RuneSelf {
			// Slow path.
			return extensions[strings.ToLower(ext)]
		}
		if 'A' <= c && c <= 'Z' {
			lower = append(lower, c+('a'-'A'))
		} else {
			lower = append(lower, c)
		}
	}
	// The conversion from []byte to string doesn't allocate in
	// a map lookup.
	return extensions[string(lower)]
}
747882
func IsCmdNotFoundErr(err error) bool {
	err = errors.Cause(err)
	if os.IsNotExist(err) {
		// Executable could not be found, go 1.3 and later
		return true
	}
	if err == exec.ErrNotFound {
		return true
	}
	if execErr, ok := err.(*exec.Error); ok {
		// Executable could not be found, go 1.2
		if os.IsNotExist(execErr.Err) || execErr.Err == exec.ErrNotFound {
			return true
		}
	}
	return false
}
214961
func executable(path string, s os.FileInfo) bool {
	return filepath.Ext(path) == ".exe"
}
1031535
func GetAbsolutePath(bin string) (string, error) {
	lp, err := exec.LookPath(bin)
	if err != nil {
		return "", fmt.Errorf("failed to resolve path to %q executable: %v", bin, err)
	}

	return filepath.EvalSymlinks(lp)
}
292761
func IsWindowsLocalPath(goos, path string) bool {
	if goos != "windows" {
		return false
	}
	if IsWindowsUNCPath(goos, path) {
		return false
	}
	if strings.Contains(path, ":") {
		return false
	}
	if !(strings.HasPrefix(path, `/`) || strings.HasPrefix(path, `\`)) {
		return false
	}
	return true
}
262565
func IsDir(fpath string) bool {
	d := cleanPath(fpath)
	if fi, err := os.Stat(d); err == nil {
		return fi.IsDir()
	}
	return false
}
1283280
func (c *FileCacher) IsExist(key string) bool {
	return com.IsExist(c.filepath(key))
}
1349697
func ExecutableFilename(name string) string {
	if strings.HasSuffix(name, ".exe") {
		return name
	}
	return fmt.Sprintf("%s.exe", name)
}
286003
func IsDirectory(path string) (bool, error) {
	fileInfo, err := os.Stat(path)
	if err != nil {
		return false, errors.Wrapf(err, "Error calling os.Stat on file %s", path)
	}
	return fileInfo.IsDir(), nil
}
1029375
func ExecutableFolder() (string, error) {
	p, err := Executable()
	if err != nil {
		return "", err
	}

	return filepath.Dir(p), nil
}
640828
func (m FileMode) IsFile() bool {
	return m == Regular ||
		m == Deprecated ||
		m == Executable ||
		m == Symlink
}
89112
func (p *Paths) initAppExecutable(os, appName string) {
	switch os {
	case "darwin":
		if appName == "" {
			appName = "Electron"
		}
		p.appExecutable = filepath.Join(p.electronDirectory, appName+".app", "Contents", "MacOS", appName)
	case "linux":
		p.appExecutable = filepath.Join(p.electronDirectory, "electron")
	case "windows":
		p.appExecutable = filepath.Join(p.electronDirectory, "electron.exe")
	}
}
377593
function isExecutable(path) {
    if (!fs_1.existsSync(path))
        return false;
    try {
        var stats = fs_1.statSync(path);
        if (chek_1.isWindows()) { // just return if is file, not ideal.
            return stats && stats.isFile();
        }
        else {
            var hasGroup = stats.gid
                ? process.getgid && stats.gid === process.getgid()
                : true;
            var hasUser = stats.uid
                ? process.getuid && stats.uid === process.getuid()
                : true;
            // just didn't want additional depend.
            // see https://github.com/kevva/executable/blob/master/index.js#L13
            return Boolean((stats.mode & parseInt('0001', 8)) ||
                ((stats.mode & parseInt('0010', 8)) && hasGroup) ||
                ((stats.mode & parseInt('0100', 8)) && hasUser));
        }
    }
    catch (ex) {
        return false;
    }
}