-
Notifications
You must be signed in to change notification settings - Fork 0
/
path.ss
29 lines (23 loc) · 1.14 KB
/
path.ss
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
#lang scheme/base
(require scheme/file
"base.ss")
; (parameter path)
(define autoplanet-root
(make-parameter (build-path (current-directory) "autoplanet")))
; -> void
(define (make-autoplanet-root)
(cond [(directory-exists? (autoplanet-root)) (void)]
[(file-exists? (autoplanet-root)) (error "autoplanet-path is a file" (autoplanet-root))]
[(link-exists? (autoplanet-root)) (error "autoplanet-path is a link" (autoplanet-root))]
[else (make-directory (autoplanet-root))]))
; -> void
(define (delete-autoplanet-root)
(cond [(directory-exists? (autoplanet-root)) (delete-directory/files (autoplanet-root))]
[(file-exists? (autoplanet-root)) (error "autoplanet-path is a file" (autoplanet-root))]
[(link-exists? (autoplanet-root)) (error "autoplanet-path is a link" (autoplanet-root))]
[else (void)]))
; Provide statements -----------------------------
(provide/contract
[autoplanet-root (parameter/c (and/c path? absolute-path?))]
[make-autoplanet-root (-> void?)]
[delete-autoplanet-root (-> void?)])