-
Notifications
You must be signed in to change notification settings - Fork 3
/
files.rkt
63 lines (55 loc) · 2.05 KB
/
files.rkt
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#lang racket/base
; files.rkt
; definitions of file paths that ivy uses
(require images/compile-time
(for-syntax racket/base racket/draw)
racket/file)
(provide (all-defined-out))
(define ivy-version "2.3.1")
; base directory where ivy will put all of its files
(define ivy-path
(case (system-type)
[(unix)
; check XDG variable first, then default to ~/.config/ivy
(let ([xdg (getenv "XDG_CONFIG_HOME")])
(if xdg
(build-path xdg "ivy")
(build-path (find-system-path 'home-dir)
".config/ivy")))]
[(windows)
(normal-case-path
(build-path (find-system-path 'home-dir)
"appdata/local/ivy"))]
[(macosx)
(build-path (find-system-path 'home-dir)
"Library/Application Support/ivy")]))
(define master-file (build-path ivy-path "catalog.sqlite"))
(define config-file (build-path ivy-path "config.rktd"))
; path for cached thumbnails
; - on *NIX, use ~/.cache/thumbnails/normal
(define thumbnails-path
(if (eq? (system-type) 'unix)
(let ([xdg (getenv "XDG_CACHE_HOME")])
(if xdg
(build-path xdg "thumbnails/normal")
(build-path (find-system-path 'home-dir)
".cache/thumbnails/normal")))
(build-path ivy-path "thumbnails")))
(begin-for-syntax
(define logo
(if (eq? (system-type) 'unix)
(let* ([base "share/icons/hicolor/128x128/apps/ivy-logo-128px.png"]
[uls (build-path "/usr/local" base)]
[us (build-path "/usr" base)])
(cond [(file-exists? uls) uls]
[(file-exists? us) us]
[else (build-path "img/ivy-logo-128px.png")]))
(build-path "img/ivy-logo-128px.png"))))
(define logo-bmp (compiled-bitmap (read-bitmap logo)))
; create the config directory
(unless (directory-exists? ivy-path)
(make-directory* ivy-path))
(unless (directory-exists? thumbnails-path)
(make-directory* thumbnails-path)
(unless (eq? (system-type) 'windows)
(file-or-directory-permissions thumbnails-path #o700)))