diff options
author | Alexandru-Sergiu Marton <brown121407@posteo.ro> | 2020-07-15 17:29:22 +0300 |
---|---|---|
committer | Alexandru-Sergiu Marton <brown121407@posteo.ro> | 2020-07-15 17:29:22 +0300 |
commit | de44d51d110bcc4c4a2868a05e666610e3842602 (patch) | |
tree | c8d08a8f6991de5068e7285b88504a27d9342adf | |
parent | fbcb5abbb9fc05a902f90a1a97abb640c6a8fd8d (diff) |
Fix modules.
-rw-r--r-- | f.scm | 70 | ||||
-rw-r--r-- | f/ports.scm | 30 | ||||
-rw-r--r-- | f/re-exports.scm | 17 |
3 files changed, 73 insertions, 44 deletions
@@ -1,4 +1,4 @@ -;; Copyright 2020 Alexandru-Sergiu Marton <brown121407@member.fsf.org> +;; Copyright 2020 Alexandru-Sergiu Marton <brown121407@posteo.ro> ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -12,24 +12,6 @@ ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see <https://www.gnu.org/licenses/>. -(define-module (f re-exports) - #:re-export (mkdir)) - -(define-module (f ports) - #:use-module ((ice-9 binary-ports) #:prefix i9:) - #:use-module ((ice-9 textual-ports) #:prefix i9:) - #:export (read-line - read-lines)) - -(define (read-line port) - (i9:get-line port)) - -(define (read-lines port) - (letrec ((loop (lambda (l ls) - (if (eof-object? l) - ls - (loop (i9:get-line port) (cons l ls)))))) - (reverse (loop (i9:get-line port) '())))) (define-module (f) #:use-module ((ice-9 binary-ports) #:prefix i9:) @@ -48,8 +30,8 @@ ls mkdir delete - traverse - copy) + traverse + copy) #:re-export (chown chmod (rename-file . move) @@ -122,7 +104,7 @@ (define* (ls #:optional (dir (getcwd)) #:key (hidden #f)) (letrec ((d (opendir dir)) - (ls' (lambda (f fs) + (ls' (lambda (f fs) (if (eof-object? f) fs (ls' (readdir d) (cons f fs)))))) @@ -135,14 +117,14 @@ (define* (traverse path f #:key (files-only #f)) (if (file-is-directory? path) (letrec ((contents (ls path #:hidden #t)) - (loop (lambda (contents) - (when (not (null? contents)) - (let ((file (string-append path "/" (car contents)))) - (traverse file f #:files-only files-only)) - (loop (cdr contents)))))) - (when (not files-only) - (f path)) - (loop contents)) + (loop (lambda (contents) + (when (not (null? contents)) + (let ((file (string-append path "/" (car contents)))) + (traverse file f #:files-only files-only)) + (loop (cdr contents)))))) + (when (not files-only) + (f path)) + (loop contents)) (f path))) (define (dir-is-empty? path) @@ -171,19 +153,19 @@ appending a #t at the end.")))))) (define* (copy src dest #:optional (recursive #f)) (if (file-is-directory? src) (let* ((contents (ls src #:hidden #t)) - (empty (null? contents))) - (if empty - (mkdir dest) - (if recursive - (letrec ((loop (lambda (contents) - (when (not (null? contents)) - (copy - (string-append src "/" (car contents)) - (string-append dest "/" (car contents)) - recursive) - (loop (cdr contents)))))) - (mkdir dest) - (loop contents)) - (throw 'f.scm "Can't copy: directory not empty. Try with making the call recursive + (empty (null? contents))) + (if empty + (mkdir dest) + (if recursive + (letrec ((loop (lambda (contents) + (when (not (null? contents)) + (copy + (string-append src "/" (car contents)) + (string-append dest "/" (car contents)) + recursive) + (loop (cdr contents)))))) + (mkdir dest) + (loop contents)) + (throw 'f.scm "Can't copy: directory not empty. Try with making the call recursive by appending a #t at the end.")))) (copy-file src dest))) diff --git a/f/ports.scm b/f/ports.scm new file mode 100644 index 0000000..ce415f8 --- /dev/null +++ b/f/ports.scm @@ -0,0 +1,30 @@ +;; Copyright 2020 Alexandru-Sergiu Marton <brown121407@posteo.ro> +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +(define-module (f ports) + #:use-module ((ice-9 binary-ports) #:prefix i9:) + #:use-module ((ice-9 textual-ports) #:prefix i9:) + #:export (read-line + read-lines)) + +(define (read-line port) + (i9:get-line port)) + +(define (read-lines port) + (letrec ((loop (lambda (l ls) + (if (eof-object? l) + ls + (loop (i9:get-line port) (cons l ls)))))) + (reverse (loop (i9:get-line port) '())))) diff --git a/f/re-exports.scm b/f/re-exports.scm new file mode 100644 index 0000000..092e496 --- /dev/null +++ b/f/re-exports.scm @@ -0,0 +1,17 @@ +;; Copyright 2020 Alexandru-Sergiu Marton <brown121407@posteo.ro> +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +(define-module (f re-exports) + #:re-export (mkdir)) |