aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-14 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-14 20:20:20 +0100
commitcb73fe80e349decb4dc39113047fb554c2ffd2b6 (patch)
tree9496aa7be64e46b27e5bf7e8237b0fee9b055a1b
parentmake (diff)
downloadhardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.gz
hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.bz2
hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.xz
hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.zst
hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.zip
up
-rw-r--r--Makefile5
-rw-r--r--c_init.go32
-rw-r--r--c_josh.go4
3 files changed, 18 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index ce7ef3a..4560bb8 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
# ========================
#
# josh: Makefile
-# Thu, 14 Dec 2023 15:00:12 +0100
+# Thu, 14 Dec 2023 15:33:28 +0100
# Joe
#
# GNU Makefile
@@ -24,3 +24,6 @@ run:
all:
@go build
+
+clean:
+ @go clean
diff --git a/c_init.go b/c_init.go
index 715130f..37ab550 100644
--- a/c_init.go
+++ b/c_init.go
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* josh: src/c_init.go
- * Thu, 14 Dec 2023 14:02:17 +0100
+ * Thu, 14 Dec 2023 15:37:10 +0100
* Joe
*
* init functions
@@ -57,30 +57,24 @@ import (
// $HOME/.local/share. It returns the full data directory path.
func c_get_data_dir() string {
var ptr *string
- home := os.Getenv("HOME")
- xdg_home := os.Getenv("XDG_DATA_HOME")
-
- if len(home) == 0 {
+ var home string
+ if home = os.Getenv("HOME"); len(home) == 0 {
c_die("env variable HOME not defined", nil)
}
+ xdg_home := os.Getenv("XDG_DATA_HOME")
+
if len(xdg_home) > 0 {
ptr = &xdg_home
- if _, err := os.Stat(*ptr); os.IsNotExist(err) {
- if err := os.MkdirAll(*ptr, os.ModePerm); err != nil {
- c_die("could not create path " + *ptr, err)
- }
- fmt.Println("created folder path " + *ptr)
- }
} else {
ptr = &home
- *ptr = *ptr + ".local/share"
- if _, err := os.Stat(*ptr); os.IsNotExist(err) {
- if err := os.MkdirAll(*ptr, os.ModePerm); err != nil {
- c_die("could not create path " + *ptr, err)
- }
- fmt.Println("created folder path " + *ptr)
- }
- return home
+ *ptr += "/.local/share"
+ }
+ *ptr += "/josh"
+ if _, err := os.Stat(*ptr); os.IsNotExist(err) {
+ if err := os.MkdirAll(*ptr, os.ModePerm); err != nil {
+ c_die("could not create path " + *ptr, err)
+ }
+ fmt.Println("created folder path " + *ptr)
}
return *ptr
}
diff --git a/c_josh.go b/c_josh.go
index ad35c80..451f837 100644
--- a/c_josh.go
+++ b/c_josh.go
@@ -54,8 +54,6 @@ import (
func main() {
var data_dir string
- if data_dir = c_get_data_dir() + "/josh"; len(data_dir) == 0 {
- c_die("couldn't find josh home directory", nil)
- }
+ data_dir = c_get_data_dir()
fmt.Println("data dir: ", data_dir)
}