summaryrefslogtreecommitdiff
path: root/common.go
blob: 368d39c10274a9387028bfae61cfc2904d3d17d5 (plain)
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
package config

import (
	"os"
	"runtime"
	"strings"
)

// todo: move these somewhere else

// a simple function name shortcut
func Exists(filename string) bool {
	_, err := os.Stat(Path(filename))
	if os.IsNotExist(err) {
		return false
	}
	return true
}

// simple function name shortcut
func IsDir(dirname string) bool {
	info, err := os.Stat(Path(dirname))
	if os.IsNotExist(err) {
		return false
	}
	return info.IsDir()
}

// notsure if this is a thing anymore. don't care much either
func Path(filename string) string {
	if runtime.GOOS == "windows" {
		filename = strings.Replace(filename, "/", "\\", -1)
	}
	return filename
}