aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
diff options
context:
space:
mode:
authorPetter Rasmussen2016-01-11 21:36:33 +0100
committerPetter Rasmussen2016-01-16 22:09:45 +0100
commit137298be0c1ec3e95825971fa25f0877ec884ad4 (patch)
tree05a9c5950df2adddae5818bfad7699bd9bc07ebe /util.go
parent3c7e4127ab7722146ab688dbe0c39e73d8a08b8b (diff)
downloadgdrive-137298be0c1ec3e95825971fa25f0877ec884ad4.tar.bz2
Basic list and download support
Diffstat (limited to 'util.go')
-rw-r--r--util.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..064ce3f
--- /dev/null
+++ b/util.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "runtime"
+ "path/filepath"
+ "fmt"
+ "os"
+)
+
+func GetDefaultConfigDir() string {
+ return filepath.Join(Homedir(), ".gdrive")
+}
+
+func GetDefaultTokenFilePath() string {
+ return filepath.Join(GetDefaultConfigDir(), "token.json")
+}
+
+func Homedir() string {
+ if runtime.GOOS == "windows" {
+ return os.Getenv("APPDATA")
+ }
+ return os.Getenv("HOME")
+}
+
+func ExitF(format string, a ...interface{}) {
+ fmt.Fprintf(os.Stderr, format, a...)
+ fmt.Println("")
+ os.Exit(1)
+}