~ chicken-core (chicken-5) 317aa19f7ee8c3d0720142ad2858d1dd7baeda83


commit 317aa19f7ee8c3d0720142ad2858d1dd7baeda83
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Sun Mar 11 13:53:04 2018 +1300
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Sun Mar 11 11:19:59 2018 +0100

    A few chicken.file and chicken.file.posix module changes
    
    Move the following procedures into the "chicken.file.posix" module:
    
      create-fifo create-symbolic-link read-symbolic-link file-type
      block-device? character-device? directory? regular-file? socket?
      fifo? symbolic-link?
    
    Introduce a local version of `symbolic-link?' in file.scm and
    subsequently drop the file unit's dependency on posix. Replace all use
    of `directory?' with `directory-exists?' throughout the source tree.
    
    Rename `file-{copy,move}' to `{copy,move}-file' for consistency with the
    the other file management procedures in the "chicken.file" module.
    
    Add a "clobber" argument to `rename-file' and make it avoid overwriting
    files by default, again for consistency.
    
    Check the "clobber" flag before hitting the filesystem when validating
    arguments to `{copy,move,rename}-file', since the second test is not
    necessary when "clobber" is true. Standardise the parameter names and
    error messages across these three procedures.
    
    Rename the permission-related procedures in "chicken.file" from
    `file-{read,write,execute}-access?' to `file-{read,writ,execut}able?'.
    
    Use C_c_string() instead of of C_data_pointer() when handling c-string
    arguments in the file and posix units.
    
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/NEWS b/NEWS
index e7486888..ceda95b7 100644
--- a/NEWS
+++ b/NEWS
@@ -78,6 +78,10 @@
     good pseudo random number generator (WELL512).
   - `glob` now returns an empty list for non-existent or inaccessible
     directories, instead of erroring out.
+  - `file-copy' and `file-move' have been renamed to `copy-file' and
+    `move-file', for consistency with `delete-file' and `rename-file'.
+  - `rename-file' now refuses to overwrite an existing file unless an
+    optional "clobber" argument is provided.
 
 - Module system
   - The compiler has been modularised, for improved namespacing.  This
diff --git a/chicken-install.scm b/chicken-install.scm
index 7e9ddd1f..7195d3fb 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -112,7 +112,7 @@
         (get-environment-variable "DYLD_LIBRARY_PATH")))
 
 (define (probe-dir dir)
-  (and dir (directory? dir) dir))
+  (and dir (directory-exists? dir) dir))
 
 (define cache-directory
   (or (get-environment-variable "CHICKEN_EGG_CACHE")
@@ -528,10 +528,10 @@
                           (hf2 (string-append here "/" f)))
                       (and (<= (file-modification-time tf2)
                                (file-modification-time hf2))
-                           (if (directory? tf2)
-                               (and (directory? hf2)
+                           (if (directory-exists? tf2)
+                               (and (directory-exists? hf2)
                                     (walk tf2 hf2))
-                               (not (directory? hf2)))))))
+                               (not (directory-exists? hf2)))))))
              tfs))))
 
 
@@ -862,8 +862,7 @@
          (version (caddr egg))
          (testdir (make-pathname dir "tests"))
          (tscript (make-pathname testdir "run.scm")))
-    (if (and (file-exists? testdir)
-             (directory? testdir)
+    (if (and (directory-exists? testdir)
              (file-exists? tscript))
         (let ((old (current-directory))
               (cmd (string-append default-csi " -s " tscript " " name " " (or version ""))))
@@ -952,7 +951,7 @@
         (with-output-to-file dbfile
           (lambda ()
             (for-each (lambda (x) (write x) (newline)) db)))
-        (file-copy dbfile (make-pathname (install-path) +module-db+) #t))))
+        (copy-file dbfile (make-pathname (install-path) +module-db+) #t))))
 
 
 ;; purge cache for given (or all) eggs
diff --git a/chicken.h b/chicken.h
index 150736c4..ea957998 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1270,8 +1270,6 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret;
 #define C_string_compare(to, from, n)   C_fix(C_memcmp(C_c_string(to), C_c_string(from), C_unfix(n)))
 #define C_string_compare_case_insensitive(from, to, n) \
                                         C_fix(C_memcasecmp(C_c_string(from), C_c_string(to), C_unfix(n)))
-#define C_rename_file(old, new)         C_fix(rename(C_c_string(old), C_c_string(new)))
-#define C_delete_file(fname)            C_fix(remove(C_c_string(fname)))
 #define C_poke_double(b, i, n)          (((double *)C_data_pointer(b))[ C_unfix(i) ] = C_c_double(n), C_SCHEME_UNDEFINED)
 #define C_poke_c_string(b, i, from, s)  (C_strlcpy((char *)C_block_item(b, C_unfix(i)), C_data_pointer(from), s), C_SCHEME_UNDEFINED)
 #define C_peek_fixnum(b, i)             C_fix(C_block_item(b, C_unfix(i)))
diff --git a/file.scm b/file.scm
index 0dc721a9..7033c4a7 100644
--- a/file.scm
+++ b/file.scm
@@ -35,13 +35,13 @@
 
 (declare
   (unit file)
-  (uses extras irregex pathname posix)
+  (uses extras irregex pathname)
   (fixnum)
   (disable-interrupts)
   (foreign-declare #<<EOF
 #include <errno.h>
 
-#define C_test_access(fn, m) C_fix(access((char *)C_data_pointer(fn), C_unfix(m)))
+#define C_test_access(fn, m) C_fix(access(C_c_string(fn), C_unfix(m)))
 
 /* For Windows */
 #ifndef R_OK
@@ -54,6 +54,8 @@
 # define X_OK 2
 #endif
 
+#define C_rename(old, new)  C_fix(rename(C_c_string(old), C_c_string(new)))
+#define C_remove(str)       C_fix(remove(C_c_string(str)))
 #define C_rmdir(str)        C_fix(rmdir(C_c_string(str)))
 
 #ifndef _WIN32
@@ -149,38 +151,26 @@ readdir(DIR * dir)
 #define C_closedir(h)       (closedir((DIR *)C_block_item(h, 0)), C_SCHEME_UNDEFINED)
 #define C_foundfile(e,b,l)  (C_strlcpy(C_c_string(b), ((struct dirent *) C_block_item(e, 0))->d_name, l), C_fix(strlen(((struct dirent *) C_block_item(e, 0))->d_name)))
 
+static C_word C_fcall C_u_i_symbolic_linkp(C_word path)
+{
+#if !defined(_WIN32) || defined(__CYGWIN__)
+  struct stat buf;
+  if (lstat(C_c_string(path), &buf) == 0)
+    return C_mk_bool(S_ISLNK(buf.st_mode));
+#endif
+  return C_SCHEME_FALSE;
+}
+
 EOF
 ))
 
 (module chicken.file
-  (block-device?
-   character-device?
-   create-directory
-   create-fifo
-   create-symbolic-link
-   create-temporary-directory
-   create-temporary-file
-   delete-directory
-   delete-file
-   delete-file*
-   directory
-   directory-exists?
-   directory?
-   fifo?
-   file-copy
-   file-execute-access?
-   file-exists?
-   file-move
-   file-read-access?
-   file-type
-   file-write-access?
-   find-files
-   glob
-   read-symbolic-link
-   regular-file?
-   rename-file
-   socket?
-   symbolic-link?)
+  (create-directory delete-directory
+   create-temporary-file create-temporary-directory
+   delete-file delete-file* copy-file move-file rename-file
+   file-exists? directory-exists?
+   file-readable? file-writable? file-executable?
+   directory find-files glob)
 
 (import scheme
 	chicken.base
@@ -190,8 +180,7 @@ EOF
 	chicken.io
 	chicken.irregex
 	chicken.pathname
-	chicken.process-context
-	chicken.posix) ; FIXME file should not depend on posix
+	chicken.process-context)
 
 (include "common-declarations.scm")
 
@@ -207,6 +196,9 @@ EOF
       (let ([rn (##sys#update-errno)])
 	(apply ##sys#signal-hook type loc (string-append msg " - " (strerror rn)) args) ) ) ) )
 
+
+;;; Existence checks:
+
 (define (file-exists? name)
   (##sys#check-string name 'file-exists?)
   (and (##sys#file-exists? name #f #f 'file-exists?) name))
@@ -215,31 +207,6 @@ EOF
   (##sys#check-string name 'directory-exists?)
   (and (##sys#file-exists? name #f #t 'directory-exists?) name))
 
-(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)
-
 
 ;;; Permissions:
 
@@ -255,9 +222,9 @@ EOF
 	    #f
 	    (posix-error #:file-error loc "cannot access file" filename)))))
 
-(define (file-read-access? filename) (test-access filename _r_ok 'file-read-access?))
-(define (file-write-access? filename) (test-access filename _w_ok 'file-write-access?))
-(define (file-execute-access? filename) (test-access filename _x_ok 'file-execute-access?))
+(define (file-readable? filename) (test-access filename _r_ok 'file-readable?))
+(define (file-writable? filename) (test-access filename _w_ok 'file-writable?))
+(define (file-executable? filename) (test-access filename _x_ok 'file-executable?))
 
 
 ;;; Directories:
@@ -287,6 +254,9 @@ EOF
 		    (loop)
 		    (cons file (loop)))))))))
 
+(define-inline (*symbolic-link? name loc)
+  (##core#inline "C_u_i_symbolic_linkp" (##sys#make-c-string name loc)))
+
 (define-inline (*create-directory loc name)
   (unless (fx= 0 (##core#inline "C_mkdir" (##sys#make-c-string name loc)))
     (posix-error #:file-error loc "cannot create directory" name)))
@@ -299,7 +269,7 @@ EOF
       (if recursive
 	  (let loop ((dir (let-values (((dir file ext) (decompose-pathname name)))
 			    (if file (make-pathname dir file ext) dir))))
-	    (when (and dir (not (directory? dir)))
+	    (when (and dir (not (directory-exists? dir)))
 	      (loop (pathname-directory dir))
 	      (*create-directory 'create-directory dir)))
 	  (*create-directory 'create-directory name)))
@@ -319,8 +289,8 @@ EOF
 		      follow-symlinks: #f)))
 	  (for-each
 	   (lambda (f)
-	     ((cond ((symbolic-link? f) delete-file)
-		    ((directory? f) rmdir)
+	     ((cond ((*symbolic-link? f 'delete-directory) delete-file)
+		    ((directory-exists? f) rmdir)
 		    (else delete-file))
 	      f))
 	   files)
@@ -328,26 +298,46 @@ EOF
 	(rmdir name))))
 
 
-;;; file-copy and file-move : they do what you'd think.
+;;; File management:
+
+(define (delete-file filename)
+  (##sys#check-string filename 'delete-file)
+  (unless (eq? 0 (##core#inline "C_remove" (##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 (delete-file* file)
+  (and (file-exists? file) (delete-file file)))
+
+(define (rename-file oldfile newfile #!optional (clobber #f))
+  (##sys#check-string oldfile 'rename-file)
+  (##sys#check-string newfile 'rename-file)
+  (when (and (not clobber) (file-exists? newfile))
+    (##sys#error 'rename-file "newfile exists but clobber is false" newfile))
+  (unless (eq? 0 (##core#inline
+		  "C_rename"
+		  (##sys#make-c-string oldfile 'rename-file)
+		  (##sys#make-c-string newfile 'rename-file)))
+    (##sys#update-errno)
+    (##sys#signal-hook
+     #:file-error 'rename-file
+     (##sys#string-append "cannot rename file - " strerror) oldfile newfile))
+  newfile)
 
-(define (file-copy origfile newfile #!optional (clobber #f) (blocksize 1024))
-  (##sys#check-string origfile 'file-copy)
-  (##sys#check-string newfile 'file-copy)
-  (##sys#check-number blocksize 'file-copy)
+(define (copy-file oldfile newfile #!optional (clobber #f) (blocksize 1024))
+  (##sys#check-string oldfile 'copy-file)
+  (##sys#check-string newfile 'copy-file)
+  (##sys#check-number blocksize 'copy-file)
   (unless (and (integer? blocksize) (> blocksize 0))
-    (##sys#error
-     'file-copy
-     "invalid blocksize given: not a positive integer"
-     blocksize))
-  (and (file-exists? newfile)
-       (or clobber
-	   (##sys#error
-	    'file-copy
-	    "newfile exists but clobber is false"
-	     newfile)))
-  (when (directory-exists? origfile)
-    (##sys#error 'file-copy "can not copy directories" origfile))
-  (let* ((i (open-input-file origfile #:binary))
+    (##sys#error 'copy-file "invalid blocksize - not a positive integer" blocksize))
+  (when (directory-exists? oldfile)
+    (##sys#error 'copy-file "cannot copy directories" oldfile))
+  (when (and (not clobber) (file-exists? newfile))
+    (##sys#error 'copy-file "newfile exists but clobber is false" newfile))
+  (let* ((i (open-input-file oldfile #:binary))
 	 (o (open-output-file newfile #:binary))
 	 (s (make-string blocksize)))
     (let loop ((d (read-string! blocksize s i))
@@ -361,24 +351,17 @@ EOF
 	    (write-string s d o)
 	    (loop (read-string! blocksize s i) (fx+ d l)))))))
 
-(define (file-move origfile newfile #!optional (clobber #f) (blocksize 1024))
-  (##sys#check-string origfile 'file-move)
-  (##sys#check-string newfile 'file-move)
-  (##sys#check-number blocksize 'file-move)
+(define (move-file oldfile newfile #!optional (clobber #f) (blocksize 1024))
+  (##sys#check-string oldfile 'move-file)
+  (##sys#check-string newfile 'move-file)
+  (##sys#check-number blocksize 'move-file)
   (unless (and (integer? blocksize) (> blocksize 0))
-    (##sys#error
-     'file-move
-     "invalid blocksize given: not a positive integer"
-     blocksize))
-  (when (directory-exists? origfile)
-    (##sys#error 'file-move "can not move directories" origfile))
-  (and (file-exists? newfile)
-       (or clobber
-	   (##sys#error
-	    'file-move
-	    "newfile exists but clobber is false"
-	    newfile)))
-  (let* ((i (open-input-file origfile #:binary))
+    (##sys#error 'move-file "invalid blocksize - not a positive integer" blocksize))
+  (when (directory-exists? oldfile)
+    (##sys#error 'move-file "cannot move directories" oldfile))
+  (when (and (not clobber) (file-exists? newfile))
+    (##sys#error 'move-file "newfile exists but clobber is false" newfile))
+  (let* ((i (open-input-file oldfile #:binary))
 	 (o (open-output-file newfile #:binary))
 	 (s (make-string blocksize)))
     (let loop ((d (read-string! blocksize s i))
@@ -387,7 +370,7 @@ EOF
 	  (begin
 	    (close-input-port i)
 	    (close-output-port o)
-	    (delete-file origfile)
+	    (delete-file oldfile)
 	    l)
 	  (begin
 	    (write-string s d o)
@@ -498,9 +481,9 @@ EOF
 	  (let* ((filename (##sys#slot fs 0))
 		 (f (make-pathname dir filename))
 		 (rest (##sys#slot fs 1)))
-	    (cond ((directory? f)
+	    (cond ((directory-exists? f)
 		   (cond ((member filename '("." "..")) (loop dir rest r))
-			 ((and (symbolic-link? f) (not follow-symlinks))
+			 ((and (*symbolic-link? f 'find-files) (not follow-symlinks))
 			  (loop dir rest (if (pproc f) (action f r) r)))
 			 ((lproc f)
 			  (loop dir
diff --git a/posix-common.scm b/posix-common.scm
index 2805bd27..2b3ab43d 100644
--- a/posix-common.scm
+++ b/posix-common.scm
@@ -37,7 +37,7 @@ static C_TLS struct stat C_statbuf;
 #define C_stat_type         (C_statbuf.st_mode & S_IFMT)
 #define C_stat_perm         (C_statbuf.st_mode & ~S_IFMT)
 
-#define C_u_i_stat(fn)      C_fix(C_stat((char *)C_data_pointer(fn), &C_statbuf))
+#define C_u_i_stat(fn)      C_fix(C_stat(C_c_string(fn), &C_statbuf))
 #define C_u_i_fstat(fd)     C_fix(fstat(C_unfix(fd), &C_statbuf))
 
 #ifndef S_IFSOCK
diff --git a/posix.scm b/posix.scm
index 0129dbd3..6b631964 100644
--- a/posix.scm
+++ b/posix.scm
@@ -48,7 +48,7 @@
    current-effective-user-name current-group-id current-process-id
    current-user-id current-user-name
    directory? duplicate-fileno fcntl/dupfd fcntl/getfd
-   fcntl/getfl fcntl/setfd fcntl/setfl fifo? fifo? file-access-time
+   fcntl/getfl fcntl/setfd fcntl/setfl fifo? file-access-time
    file-change-time file-close file-control file-creation-mode
    file-group file-link file-lock
    file-lock/blocking file-mkstemp file-modification-time file-open
@@ -147,12 +147,15 @@
 (define errno/xdev _exdev))
 
 (module chicken.file.posix
-  (duplicate-fileno fcntl/dupfd fcntl/getfd fcntl/getfl fcntl/setfd
+  (create-fifo create-symbolic-link read-symbolic-link
+   duplicate-fileno fcntl/dupfd fcntl/getfd fcntl/getfl fcntl/setfd
    fcntl/setfl file-access-time file-change-time file-modification-time
    file-close file-control file-creation-mode file-group file-link
    file-lock file-lock/blocking file-mkstemp file-open file-owner
    file-permissions file-position file-read file-select file-size
    file-stat file-test-lock file-truncate file-unlock file-write
+   file-type block-device? character-device? directory? fifo?
+   regular-file? socket? symbolic-link?
    fileno/stderr fileno/stdin fileno/stdout
    open-input-file* open-output-file*
    open/append open/binary open/creat open/excl open/fsync open/noctty
diff --git a/posixunix.scm b/posixunix.scm
index 02dec49a..e66144fb 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -115,9 +115,9 @@ static C_TLS struct stat C_statbuf;
 #define C_getgid            getgid
 #define C_geteuid           geteuid
 #define C_getegid           getegid
-#define C_chown(fn, u, g)   C_fix(chown(C_data_pointer(fn), C_unfix(u), C_unfix(g)))
+#define C_chown(fn, u, g)   C_fix(chown(C_c_string(fn), C_unfix(u), C_unfix(g)))
 #define C_fchown(fd, u, g)  C_fix(fchown(C_unfix(fd), C_unfix(u), C_unfix(g)))
-#define C_chmod(fn, m)      C_fix(chmod(C_data_pointer(fn), C_unfix(m)))
+#define C_chmod(fn, m)      C_fix(chmod(C_c_string(fn), C_unfix(m)))
 #define C_fchmod(fd, m)     C_fix(fchmod(C_unfix(fd), C_unfix(m)))
 #define C_setuid(id)        C_fix(setuid(C_unfix(id)))
 #define C_setgid(id)        C_fix(setgid(C_unfix(id)))
@@ -126,21 +126,21 @@ static C_TLS struct stat C_statbuf;
 #define C_setsid(dummy)     C_fix(setsid())
 #define C_setpgid(x, y)     C_fix(setpgid(C_unfix(x), C_unfix(y)))
 #define C_getpgid(x)        C_fix(getpgid(C_unfix(x)))
-#define C_symlink(o, n)     C_fix(symlink(C_data_pointer(o), C_data_pointer(n)))
-#define C_do_readlink(f, b)    C_fix(readlink(C_data_pointer(f), C_data_pointer(b), FILENAME_MAX))
-#define C_getpwnam(n)       C_mk_bool((C_user = getpwnam((char *)C_data_pointer(n))) != NULL)
+#define C_symlink(o, n)     C_fix(symlink(C_c_string(o), C_c_string(n)))
+#define C_do_readlink(f, b) C_fix(readlink(C_c_string(f), C_c_string(b), FILENAME_MAX))
+#define C_getpwnam(n)       C_mk_bool((C_user = getpwnam(C_c_string(n))) != NULL)
 #define C_getpwuid(u)       C_mk_bool((C_user = getpwuid(C_unfix(u))) != NULL)
 #define C_pipe(d)           C_fix(pipe(C_pipefds))
-#define C_truncate(f, n)    C_fix(truncate((char *)C_data_pointer(f), C_num_to_int(n)))
+#define C_truncate(f, n)    C_fix(truncate(C_c_string(f), C_num_to_int(n)))
 #define C_ftruncate(f, n)   C_fix(ftruncate(C_unfix(f), C_num_to_int(n)))
 #define C_alarm             alarm
 #define C_close(fd)         C_fix(close(C_unfix(fd)))
 #define C_umask(m)          C_fix(umask(C_unfix(m)))
 
-#define C_u_i_lstat(fn)     C_fix(lstat((char *)C_data_pointer(fn), &C_statbuf))
+#define C_u_i_lstat(fn)     C_fix(lstat(C_c_string(fn), &C_statbuf))
 
-#define C_u_i_execvp(f,a)   C_fix(execvp(C_data_pointer(f), (char *const *)C_c_pointer_vector_or_null(a)))
-#define C_u_i_execve(f,a,e) C_fix(execve(C_data_pointer(f), (char *const *)C_c_pointer_vector_or_null(a), (char *const *)C_c_pointer_vector_or_null(e)))
+#define C_u_i_execvp(f,a)   C_fix(execvp(C_c_string(f), (char *const *)C_c_pointer_vector_or_null(a)))
+#define C_u_i_execve(f,a,e) C_fix(execve(C_c_string(f), (char *const *)C_c_pointer_vector_or_null(a), (char *const *)C_c_pointer_vector_or_null(e)))
 
 #if defined(__FreeBSD__) || defined(C_MACOSX) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sgi__) || defined(sgi) || defined(__DragonFly__) || defined(__SUNPRO_C)
 static C_TLS int C_uw;
@@ -162,7 +162,7 @@ static C_TLS int C_uw;
 #ifdef __CYGWIN__
 # define C_mkfifo(fn, m)    C_fix(-1);
 #else
-# define C_mkfifo(fn, m)    C_fix(mkfifo((char *)C_data_pointer(fn), C_unfix(m)))
+# define C_mkfifo(fn, m)    C_fix(mkfifo(C_c_string(fn), C_unfix(m)))
 #endif
 
 #define C_flock_setup(t, s, n) (C_flock.l_type = C_unfix(t), C_flock.l_start = C_num_to_int(s), C_flock.l_whence = SEEK_SET, C_flock.l_len = C_num_to_int(n), C_SCHEME_UNDEFINED)
diff --git a/posixwin.scm b/posixwin.scm
index 38a3fbfc..574367a1 100644
--- a/posixwin.scm
+++ b/posixwin.scm
@@ -110,18 +110,18 @@ static C_TLS TCHAR C_username[255 + 1] = "";
 #define open_text_output_pipe(a, n, name)    open_binary_output_pipe(a, n, name)
 #define close_pipe(p)			     C_fix(_pclose(C_port_file(p)))
 
-#define C_chmod(fn, m)	    C_fix(chmod(C_data_pointer(fn), C_unfix(m)))
+#define C_chmod(fn, m)	    C_fix(chmod(C_c_string(fn), C_unfix(m)))
 #define C_pipe(d, m)	    C_fix(_pipe(C_pipefds, PIPE_BUF, C_unfix(m)))
 #define C_close(fd)	    C_fix(close(C_unfix(fd)))
 
 #define C_u_i_lstat(fn)     C_u_i_stat(fn)
 
-#define C_u_i_execvp(f,a)   C_fix(execvp(C_data_pointer(f), (const char *const *)C_c_pointer_vector_or_null(a)))
-#define C_u_i_execve(f,a,e) C_fix(execve(C_data_pointer(f), (const char *const *)C_c_pointer_vector_or_null(a), (const char *const *)C_c_pointer_vector_or_null(e)))
+#define C_u_i_execvp(f,a)   C_fix(execvp(C_c_string(f), (const char *const *)C_c_pointer_vector_or_null(a)))
+#define C_u_i_execve(f,a,e) C_fix(execve(C_c_string(f), (const char *const *)C_c_pointer_vector_or_null(a), (const char *const *)C_c_pointer_vector_or_null(e)))
 
 /* MS replacement for the fork-exec pair */
-#define C_u_i_spawnvp(m,f,a) C_fix(spawnvp(C_unfix(m), C_data_pointer(f), (const char *const *)C_c_pointer_vector_or_null(a)))
-#define C_u_i_spawnvpe(m,f,a,e) C_fix(spawnvpe(C_unfix(m), C_data_pointer(f), (const char *const *)C_c_pointer_vector_or_null(a), (const char *const *)C_c_pointer_vector_or_null(e)))
+#define C_u_i_spawnvp(m,f,a)    C_fix(spawnvp(C_unfix(m), C_c_string(f), (const char *const *)C_c_pointer_vector_or_null(a)))
+#define C_u_i_spawnvpe(m,f,a,e) C_fix(spawnvpe(C_unfix(m), C_c_string(f), (const char *const *)C_c_pointer_vector_or_null(a), (const char *const *)C_c_pointer_vector_or_null(e)))
 
 #define C_open(fn, fl, m)   C_fix(open(C_c_string(fn), C_unfix(fl), C_unfix(m)))
 #define C_read(fd, b, n)    C_fix(read(C_unfix(fd), C_data_pointer(b), C_unfix(n)))
diff --git a/tests/executable-tests.scm b/tests/executable-tests.scm
index 9ad7761f..52074e59 100644
--- a/tests/executable-tests.scm
+++ b/tests/executable-tests.scm
@@ -3,6 +3,7 @@
 (include "test.scm")
 
 (import (chicken file)
+        (chicken file posix)
         (chicken pathname)
         (chicken process-context)
         (chicken string))
diff --git a/tests/posix-tests.scm b/tests/posix-tests.scm
index 103f14a5..e3ccbb69 100644
--- a/tests/posix-tests.scm
+++ b/tests/posix-tests.scm
@@ -1,7 +1,8 @@
 (import (chicken pathname)
         (chicken file)
+        (chicken file posix)
         (chicken platform)
-        (chicken posix)
+        (chicken process)
         (chicken process-context)
         (chicken memory representation))
 
diff --git a/tests/private-repository-test.scm b/tests/private-repository-test.scm
index 02e730eb..d293962e 100644
--- a/tests/private-repository-test.scm
+++ b/tests/private-repository-test.scm
@@ -4,7 +4,8 @@
 (import (chicken pathname)
 	(chicken platform)
         (chicken process-context)
-        (chicken file))
+        (chicken file)
+        (chicken file posix))
 
 (define read-symbolic-link*
   (cond-expand
diff --git a/tests/test-find-files.scm b/tests/test-find-files.scm
index f09c02a1..4aa7c772 100644
--- a/tests/test-find-files.scm
+++ b/tests/test-find-files.scm
@@ -1,4 +1,5 @@
 (import (chicken file)
+        (chicken file posix)
         (chicken process-context)
         (chicken sort)
         (chicken string))
diff --git a/types.db b/types.db
index eff9f9a4..429b8f04 100644
--- a/types.db
+++ b/types.db
@@ -1568,14 +1568,14 @@
 (chicken.file#delete-file* (#(procedure #:clean #:enforce) chicken.file#delete-file* (string) *))
 (chicken.file#directory-exists? (#(procedure #:clean #:enforce) chicken.file#directory-exists? (string) (or false string)))
 (chicken.file#file-exists? (#(procedure #:clean #:enforce) chicken.file#file-exists? (string) (or false string)))
-(chicken.file#file-copy (#(procedure #:clean #:enforce) chicken.file#file-copy (string string #!optional * fixnum) fixnum))
-(chicken.file#file-move (#(procedure #:clean #:enforce) chicken.file#file-move (string string #!optional * fixnum) fixnum))
 (chicken.file#find-files (#(procedure #:enforce) chicken.file#find-files (string #!rest) list))
 (chicken.file#glob (#(procedure #:clean #:enforce) chicken.file#glob (#!rest string) list))
-(chicken.file#rename-file (#(procedure #:clean #:enforce) chicken.file#rename-file (string string) string))
-(chicken.file#file-read-access? (#(procedure #:clean #:enforce) chicken.file#file-read-access? (string) boolean))
-(chicken.file#file-write-access? (#(procedure #:clean #:enforce) chicken.file#file-write-access? (string) boolean))
-(chicken.file#file-execute-access? (#(procedure #:clean #:enforce) chicken.file#file-execute-access? (string) boolean))
+(chicken.file#copy-file (#(procedure #:clean #:enforce) chicken.file#copy-file (string string #!optional * fixnum) fixnum))
+(chicken.file#move-file (#(procedure #:clean #:enforce) chicken.file#move-file (string string #!optional * fixnum) fixnum))
+(chicken.file#rename-file (#(procedure #:clean #:enforce) chicken.file#rename-file (string string #!optional *) string))
+(chicken.file#file-readable? (#(procedure #:clean #:enforce) chicken.file#file-readable? (string) boolean))
+(chicken.file#file-writable? (#(procedure #:clean #:enforce) chicken.file#file-writable? (string) boolean))
+(chicken.file#file-executable? (#(procedure #:clean #:enforce) chicken.file#file-executable? (string) boolean))
 
 
 ;; pathname
Trap