diff options
author | Joe <rbo@gmx.us> | 2023-12-14 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2023-12-14 20:20:20 +0100 |
commit | cb73fe80e349decb4dc39113047fb554c2ffd2b6 (patch) | |
tree | 9496aa7be64e46b27e5bf7e8237b0fee9b055a1b | |
parent | make (diff) | |
download | hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.gz hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.bz2 hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.xz hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.tar.zst hardflip-cb73fe80e349decb4dc39113047fb554c2ffd2b6.zip |
up
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | c_init.go | 32 | ||||
-rw-r--r-- | c_josh.go | 4 |
3 files changed, 18 insertions, 23 deletions
@@ -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 @@ -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 } @@ -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) } |