/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osfs.h,v 1.2 1991/04/12 03:20:38 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osfs.h,v 1.3 1991/10/29 13:58:53 cph Exp $
Copyright (c) 1990-91 Massachusetts Institute of Technology
#include "os.h"
-enum file_existence { file_does_exist, file_doesnt_exist, file_may_exist };
+enum file_existence { file_does_exist, file_doesnt_exist, file_is_link };
extern enum file_existence EXFUN (OS_file_existence_test, (CONST char * name));
extern int EXFUN (OS_file_access, (CONST char * name, unsigned int mode));
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosfs.c,v 1.3 1991/04/12 03:20:45 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosfs.c,v 1.4 1991/10/29 13:58:58 cph Exp $
Copyright (c) 1987-91 Massachusetts Institute of Technology
\f
DEFINE_PRIMITIVE ("FILE-EXISTS?", Prim_file_exists_p, 1, 1,
"Return #T iff FILENAME refers to an existing file.\n\
-Otherwise #F is returned, in which case either:\n\
- (1) the file doesn't exist, or\n\
- (2) it's not possible to determine whether the file exists.")
+Return #F if the file doesn't exist.\n\
+Return zero if it's a symbolic link that points to a nonexisting file.\n\
+Signal an error if the file's existence is indeterminate.")
{
PRIMITIVE_HEADER (1);
- PRIMITIVE_RETURN
- (BOOLEAN_TO_OBJECT
- ((OS_file_existence_test (STRING_ARG (1))) == file_does_exist));
+ {
+ enum file_existence result = (OS_file_existence_test (STRING_ARG (1)));
+ PRIMITIVE_RETURN
+ ((result == file_doesnt_exist)
+ ? SHARP_F
+ : (result == file_does_exist)
+ ? SHARP_T
+ : FIXNUM_ZERO);
+ }
}
DEFINE_PRIMITIVE ("FILE-ACCESS", Prim_file_access, 2, 2,
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/pruxfs.c,v 9.45 1991/09/05 22:26:48 markf Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/pruxfs.c,v 9.46 1991/10/29 13:59:04 cph Exp $
Copyright (c) 1987-91 Massachusetts Institute of Technology
#include "ux.h"
#include "osfs.h"
+extern int EXFUN
+ (UX_read_file_status, (CONST char * filename, struct stat * s));
+extern int EXFUN
+ (UX_read_file_status_indirect, (CONST char * filename, struct stat * s));
+
static SCHEME_OBJECT EXFUN (file_attributes_internal, (struct stat * s));
static void EXFUN (file_mode_string, (struct stat * s, char * a));
static char EXFUN (file_type_letter, (struct stat * s));
struct stat stat_result;
PRIMITIVE_HEADER (1);
PRIMITIVE_RETURN
- (((UX_stat ((STRING_ARG (1)), (&stat_result))) < 0)
- ? SHARP_F
- : (LONG_TO_UNSIGNED_FIXNUM ((stat_result . st_mode) & 07777)));
+ ((UX_read_file_status_indirect ((STRING_ARG (1)), (&stat_result)))
+ ? (LONG_TO_UNSIGNED_FIXNUM ((stat_result . st_mode) & 07777))
+ : SHARP_F);
}
DEFINE_PRIMITIVE ("SET-FILE-MODES!", Prim_set_file_modes, 2, 2,
struct stat s;
PRIMITIVE_HEADER (1);
PRIMITIVE_RETURN
- (((UX_lstat ((STRING_ARG (1)), (&s))) < 0)
- ? SHARP_F
- : (long_to_integer (s . st_mtime)));
+ ((UX_read_file_status ((STRING_ARG (1)), (&s)))
+ ? (long_to_integer (s . st_mtime))
+ : SHARP_F);
}
DEFINE_PRIMITIVE ("FILE-MOD-TIME-INDIRECT", Prim_file_mod_time_indirect, 1, 1, 0)
struct stat s;
PRIMITIVE_HEADER (1);
PRIMITIVE_RETURN
- (((UX_stat ((STRING_ARG (1)), (&s))) < 0)
- ? SHARP_F
- : (long_to_integer (s . st_mtime)));
+ ((UX_read_file_status_indirect ((STRING_ARG (1)), (&s)))
+ ? (long_to_integer (s . st_mtime))
+ : SHARP_F);
}
\f
/* Returns a vector of 10 items:
struct stat s; \
PRIMITIVE_HEADER (1); \
PRIMITIVE_RETURN \
- (((stat_syscall ((STRING_ARG (1)), (&s))) < 0) \
- ? SHARP_F \
- : (file_attributes_internal (&s))); \
+ ((stat_syscall ((STRING_ARG (1)), (&s))) \
+ ? (file_attributes_internal (&s)) \
+ : SHARP_F); \
}
DEFINE_PRIMITIVE ("FILE-ATTRIBUTES", Prim_file_attributes, 1, 1,
If the file exists and its status information is accessible, the result\n\
is a vector of 10 items (see the reference manual for details). Otherwise\n\
the result is #F.")
- FILE_ATTRIBUTES_PRIMITIVE (UX_lstat)
+ FILE_ATTRIBUTES_PRIMITIVE (UX_read_file_status)
DEFINE_PRIMITIVE ("FILE-ATTRIBUTES-INDIRECT", Prim_file_attributes_indirect, 1, 1,
"Like FILE-ATTRIBUTES but indirect through symbolic links.")
- FILE_ATTRIBUTES_PRIMITIVE (UX_stat)
+ FILE_ATTRIBUTES_PRIMITIVE (UX_read_file_status_indirect)
static SCHEME_OBJECT
DEFUN (file_attributes_internal, (s), struct stat * s)
rwx ((((s -> st_mode) & 0070) << 3), (& (a [4])));
rwx ((((s -> st_mode) & 0007) << 6), (& (a [7])));
#ifdef S_ISUID
- if (((s -> st_mode) & S_ISUID) != 0)
- (a[3]) = (((a[3]) == 'x') ? 's' : 'S');
+ if (((s -> st_mode) & S_ISUID) != 0)
+ (a[3]) = (((a[3]) == 'x') ? 's' : 'S');
#endif
#ifdef S_ISGID
- if (((s -> st_mode) & S_ISGID) != 0)
- (a[6]) = (((a [6]) == 'x') ? 's' : 'S');
+ if (((s -> st_mode) & S_ISGID) != 0)
+ (a[6]) = (((a [6]) == 'x') ? 's' : 'S');
#endif
#ifdef S_ISVTX
- if (((s -> st_mode) & S_ISVTX) != 0)
- (a[9]) = (((a [9]) == 'x') ? 't' : 'T');
+ if (((s -> st_mode) & S_ISVTX) != 0)
+ (a[9]) = (((a [9]) == 'x') ? 't' : 'T');
#endif
}
\f
;;; -*-Scheme-*-
;;;
-;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.59 1991/09/05 22:27:17 markf Exp $
+;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.60 1991/10/29 13:59:11 cph Exp $
;;;
;;; Copyright (c) 1987-91 Massachusetts Institute of Technology
;;;
UTIME
VFORK
WRITE
+ STAT
+ LSTAT
))
\f
;;; [] System-call errors
;;; This identification string is saved by the system.
-"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.59 1991/09/05 22:27:17 markf Exp $"
\ No newline at end of file
+"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.60 1991/10/29 13:59:11 cph Exp $"
\ No newline at end of file
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.27 1991/10/16 00:27:02 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.28 1991/10/29 13:59:20 cph Exp $
Copyright (c) 1988-91 Massachusetts Institute of Technology
syscall_unlink,
syscall_utime,
syscall_vfork,
- syscall_write
+ syscall_write,
+ syscall_stat,
+ syscall_lstat
};
enum syserr_names
/* -*-C-*-
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfs.c,v 1.4 1991/04/12 03:20:51 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfs.c,v 1.5 1991/10/29 13:59:31 cph Exp $
Copyright (c) 1990-1 Massachusetts Institute of Technology
#include "ux.h"
#include "osfs.h"
\f
-enum file_existence
-DEFUN (OS_file_existence_test, (name), CONST char * name)
+int
+DEFUN (UX_read_file_status, (filename, s),
+ CONST char * filename AND
+ struct stat * s)
{
- struct stat s;
- return
- (((UX_stat (name, (&s))) < 0)
- ? (((errno == ENOENT) || (errno == ENOTDIR))
- ? file_doesnt_exist
- : file_may_exist)
- : file_does_exist);
+ while ((UX_lstat (filename, s)) < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOENT) || (errno == ENOTDIR))
+ return (0);
+ error_system_call (errno, syscall_lstat);
+ }
+ return (1);
}
int
-DEFUN (OS_file_access, (name, mode), CONST char * name AND unsigned int mode)
+DEFUN (UX_read_file_status_indirect, (filename, s),
+ CONST char * filename AND
+ struct stat * s)
{
- return ((UX_access (name, mode)) == 0);
+ while ((UX_stat (filename, s)) < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ if ((errno == ENOENT) || (errno == ENOTDIR))
+ return (0);
+ error_system_call (errno, syscall_stat);
+ }
+ return (1);
}
+enum file_existence
+DEFUN (OS_file_existence_test, (name), CONST char * name)
+{
+ struct stat s;
+ return
+ ((UX_read_file_status_indirect (name, (&s)))
+ ? file_does_exist
+ : (UX_read_file_status (name, (&s)))
+ ? file_is_link
+ : file_doesnt_exist);
+}
+\f
int
DEFUN (OS_file_directory_p, (name), CONST char * name)
{
struct stat s;
- return (((UX_stat (name, (&s))) == 0) &&
- (((s . st_mode) & S_IFMT) == S_IFDIR));
+ return
+ ((UX_read_file_status_indirect (name, (&s)))
+ && (((s . st_mode) & S_IFMT) == S_IFDIR));
}
CONST char *
{
#ifdef HAVE_SYMBOLIC_LINKS
struct stat s;
- if (((UX_lstat (name, (&s))) < 0)
- || (((s . st_mode) & S_IFMT) != S_IFLNK))
+ if (! ((UX_read_file_status (name, (&s)))
+ && (((s . st_mode) & S_IFMT) == S_IFLNK)))
return (0);
{
int scr;
return (0);
#endif
}
+\f
+int
+DEFUN (OS_file_access, (name, mode), CONST char * name AND unsigned int mode)
+{
+ return ((UX_access (name, mode)) == 0);
+}
void
DEFUN (OS_file_remove, (name), CONST char * name)
DEFUN (OS_file_remove_link, (name), CONST char * name)
{
struct stat s;
- if (((UX_lstat (name, (&s))) == 0) &&
- ((((s . st_mode) & S_IFMT) == S_IFREG)
+ if ((UX_read_file_status (name, (&s)))
+ && ((((s . st_mode) & S_IFMT) == S_IFREG)
#ifdef HAVE_SYMBOLIC_LINKS
- || (((s . st_mode) & S_IFMT) == S_IFLNK)
+ || (((s . st_mode) & S_IFMT) == S_IFLNK)
#endif
- ))
+ ))
UX_unlink (name);
}
;;; -*-Scheme-*-
;;;
-;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.59 1991/09/05 22:27:17 markf Exp $
+;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.60 1991/10/29 13:59:11 cph Exp $
;;;
;;; Copyright (c) 1987-91 Massachusetts Institute of Technology
;;;
UTIME
VFORK
WRITE
+ STAT
+ LSTAT
))
\f
;;; [] System-call errors
;;; This identification string is saved by the system.
-"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.59 1991/09/05 22:27:17 markf Exp $"
\ No newline at end of file
+"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.60 1991/10/29 13:59:11 cph Exp $"
\ No newline at end of file