From 3b2cd55dea9dda88491a8693d6c40a1e12424ef9 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sun, 10 Sep 2017 17:22:19 +0200 Subject: [PATCH] Move delete-file and rename-file from library.scm to file.scm Nothing really depends on it, so we can move them without problems. Fix up csc.scm's dependencies while we're at it (it also gets a new dependency on file.import.scm) --- chicken.import.scm | 2 -- csc.scm | 5 +++-- file.scm | 18 ++++++++++++++++++ library.scm | 20 -------------------- rules.make | 8 ++++++-- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/chicken.import.scm b/chicken.import.scm index ad4b677f..06212515 100644 --- a/chicken.import.scm +++ b/chicken.import.scm @@ -54,7 +54,6 @@ cplxnum? current-error-port (current-exception-handler . chicken.condition#current-exception-handler) - delete-file directory-exists? (dynamic-load-libraries . chicken.load#dynamic-load-libraries) enable-warnings @@ -155,7 +154,6 @@ quotient&remainder ratnum? (register-feature! . chicken.platform#register-feature!) - rename-file (repository-path . chicken.platform#repository-path) (require . chicken.load#require) return-to-host diff --git a/csc.scm b/csc.scm index 23241fac..15882f27 100644 --- a/csc.scm +++ b/csc.scm @@ -29,12 +29,13 @@ (import scheme chicken - chicken.posix + chicken.file chicken.foreign chicken.format chicken.io - chicken.process chicken.pathname + chicken.posix + chicken.process chicken.string) (include "egg-environment.scm") diff --git a/file.scm b/file.scm index f9f42949..69b76949 100644 --- a/file.scm +++ b/file.scm @@ -104,12 +104,30 @@ EOF (apply ##sys#signal-hook type loc (string-append msg " - " (strerror rn)) args) ) ) ) ) +(define (delete-file filename) + (##sys#check-string filename 'delete-file) + (unless (eq? 0 (##core#inline "C_delete_file" (##sys#make-c-string filename 'delete-file))) + (##sys#update-errno) + (##sys#signal-hook + #:file-error 'delete-file + (##sys#string-append "cannot delete file - " strerror) filename) ) + filename) + ;;; Like `delete-file', but does nothing if the file doesn't exist: (define delete-file* (lambda (file) (and (file-exists? file) (delete-file file)))) +(define (rename-file old new) + (##sys#check-string old 'rename-file) + (##sys#check-string new 'rename-file) + (unless (eq? 0 (##core#inline "C_rename_file" (##sys#make-c-string old 'rename-file) (##sys#make-c-string new))) + (##sys#update-errno) + (##sys#signal-hook + #:file-error 'rename-file + (##sys#string-append "cannot rename file - " strerror) old new) ) + new) ;;; Directory management: diff --git a/library.scm b/library.scm index d190fd03..d75635a9 100644 --- a/library.scm +++ b/library.scm @@ -2897,26 +2897,6 @@ EOF (##sys#values (##sys#slot port 4) (##sys#slot port 5)) (##sys#error 'port-position "cannot compute position of port" port) ) ) -(define (delete-file filename) - (##sys#check-string filename 'delete-file) - (unless (eq? 0 (##core#inline "C_delete_file" (##sys#make-c-string filename 'delete-file))) - (##sys#update-errno) - (##sys#signal-hook - #:file-error 'delete-file - (##sys#string-append "cannot delete file - " strerror) filename) ) - filename) - -(define (rename-file old new) - (##sys#check-string old 'rename-file) - (##sys#check-string new 'rename-file) - (unless (eq? 0 (##core#inline "C_rename_file" (##sys#make-c-string old 'rename-file) (##sys#make-c-string new))) - (##sys#update-errno) - (##sys#signal-hook - #:file-error 'rename-file - (##sys#string-append "cannot rename file - " strerror) old new) ) - new) - - ;;; Decorate procedure with arbitrary data ; ; warning: may modify proc, if it already has a suitable decoration! diff --git a/rules.make b/rules.make index 2308663e..1bfccfc3 100644 --- a/rules.make +++ b/rules.make @@ -640,10 +640,14 @@ modules.c: modules.scm \ chicken.platform.import.scm \ chicken.syntax.import.scm csc.c: csc.scm \ - chicken.string.import.scm \ + chicken.file.import.scm \ + chicken.foreign.import.scm \ chicken.format.import.scm \ + chicken.io.import.scm \ chicken.pathname.import.scm \ - chicken.posix.import.scm + chicken.posix.import.scm \ + chicken.process.import.scm \ + chicken.string.import.scm csi.c: csi.scm \ chicken.condition.import.scm \ chicken.data-structures.import.scm \ -- 2.11.0