Split out ensure-directory.
This commit is contained in:
parent
ed129c8760
commit
a56605fa3f
5 changed files with 61 additions and 11 deletions
|
@ -55,7 +55,7 @@ HACKERBASE-OBJS=hackerbase.o testing.o listing.o cal-month.o \
|
|||
sgr-list.o sgr-block.o table-processor.o table-border.o \
|
||||
table-style.o sgr-state.o util-utf8.o sgr-cell.o \
|
||||
template-list-expander.o box-drawing.o util-list.o \
|
||||
export-web-static.o
|
||||
export-web-static.o util-dir.o
|
||||
|
||||
.PHONY: imports
|
||||
imports: $(HACKERBASE-DEPS)
|
||||
|
@ -236,7 +236,7 @@ members-payments.import.scm: $(MEMBERS-PAYMENTS-SOURCES)
|
|||
EXPORT-WIKI-COMPAT-SOURCES=export-wiki-compat.scm brmember.import.scm \
|
||||
configuration.import.scm members-payments.import.scm \
|
||||
mbase.import.scm util-git.import.scm progress.import.scm \
|
||||
util-list.import.scm
|
||||
util-list.import.scm util-dir.import.scm
|
||||
|
||||
export-wiki-compat.o: export-wiki-compat.import.scm
|
||||
export-wiki-compat.import.scm: $(EXPORT-WIKI-COMPAT-SOURCES)
|
||||
|
@ -474,3 +474,8 @@ EXPORT-WEB-STATIC-SOURCES=export-web-static.scm brmember.import.scm
|
|||
|
||||
export-web-static.o: export-web-static.import.scm
|
||||
export-web-static.import.scm: $(EXPORT-WEB-STATIC-SOURCES)
|
||||
|
||||
UTIL-DIR-SOURCES=util-dir.scm
|
||||
|
||||
util-dir.o: util-dir.import.scm
|
||||
util-dir.import.scm: $(UTIL-DIR-SOURCES)
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
(let ((fname (format "~A.html" (brmember-id mr))))
|
||||
#f))
|
||||
|
||||
(define (gen-html-members mb)
|
||||
(define (gen-html-members mb dir)
|
||||
#f)
|
||||
|
||||
)
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
members-payments
|
||||
mbase
|
||||
util-git
|
||||
progress)
|
||||
progress
|
||||
util-dir)
|
||||
|
||||
;; Generate all the files in specified (default current) directory.
|
||||
(define (gen-web-static-member mr . dirs)
|
||||
|
@ -79,11 +80,7 @@
|
|||
|
||||
;; Generates all member files in given directory
|
||||
(define (gen-web-static mb dir)
|
||||
(when (and (file-exists? dir)
|
||||
(regular-file? dir))
|
||||
(error 'gen-web-static "Directory is a file:" dir))
|
||||
(when (not (directory-exists? dir))
|
||||
(create-directory dir))
|
||||
(ensure-directory dir)
|
||||
(let* ((members-list (find-members-by-predicate mb brmember-existing?))
|
||||
(mlen0 (length members-list))
|
||||
(mlen (if (> mlen0 0)
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
util-git
|
||||
util-dict-list
|
||||
util-stdout
|
||||
table)
|
||||
table
|
||||
export-web-static)
|
||||
|
||||
;; Command-line options and configurable parameters
|
||||
(define -needs-bank- (make-parameter #f))
|
||||
|
@ -324,7 +325,8 @@
|
|||
(repl))
|
||||
((genweb)
|
||||
(log-info "Generating static web files")
|
||||
(gen-web-static MB (-web-dir-)))
|
||||
(gen-web-static MB (-web-dir-))
|
||||
(gen-html-members MB (-web-dir-)))
|
||||
((edit)
|
||||
(if mr
|
||||
(edit-file (brmember-file-path mr))
|
||||
|
|
46
src/util-dir.scm
Normal file
46
src/util-dir.scm
Normal file
|
@ -0,0 +1,46 @@
|
|||
;;
|
||||
;; util-dir.scm
|
||||
;;
|
||||
;; Common directory manipulation utilities.
|
||||
;;
|
||||
;; ISC License
|
||||
;;
|
||||
;; Copyright 2023 Brmlab, z.s.
|
||||
;; Dominik Pantůček <dominik.pantucek@trustica.cz>
|
||||
;;
|
||||
;; Permission to use, copy, modify, and/or distribute this software
|
||||
;; for any purpose with or without fee is hereby granted, provided
|
||||
;; that the above copyright notice and this permission notice appear
|
||||
;; in all copies.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
;;
|
||||
|
||||
(declare (unit util-dir))
|
||||
|
||||
(module
|
||||
util-dir
|
||||
(
|
||||
ensure-directory
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
(chicken file)
|
||||
(chicken file posix))
|
||||
|
||||
(define (ensure-directory dir)
|
||||
(when (and (file-exists? dir)
|
||||
(regular-file? dir))
|
||||
(error 'gen-web-static "Directory is a file:" dir))
|
||||
(when (not (directory-exists? dir))
|
||||
(create-directory dir)))
|
||||
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue