blob: 21f0b8825798d36ab1bd93eb0fb9b17616cc91e2 (
plain)
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
|
(define-module (com simatime caplinks)
#:use-module ((ice-9 popen) #:prefix popen/)
#:use-module ((com simatime string) #:prefix string/)
#:use-module ((com simatime shell) #:prefix sh/)
#:export (main get-all-nodes make-symlink))
;; given a root directory, walk the tree and get a list of all the files. Then,
;; for each file, symlink a capitalized version
(define (main args)
(let* ((root (cadr args))
(files (get-all-nodes root)))
(for-each (lambda (file)
(display file)
(move-file file (capitalize-file file)))
files)
(display root) (newline)
(display "done moving files") (newline)
(newline)))
(define (get-all-nodes root)
(filter (lambda (s) (not (equal? "" s)))
(string-split (sh/stream
(format #f "find ~a -name '*.hs*'" root))
#\newline)))
(define (capitalize-file file)
(string-join (map string/capitalize (string-split file #\/))
"/"))
(define (butlast ls)
(let ((len (length ls)))
(list-head ls (- len 1))))
(define (dir-for f)
(string-join
(butlast (string-split f #\/))
"/"))
(define (move-file here there)
(display (format #f "~a -> ~a" here there))
(newline)
;; make the directory tree for the link, if it doesn't already exist
(system (format #f "mkdir -p ~a" (dir-for there)))
(system (format #f "mv ~a ~a" here there)))
|