/* -*-C-*-
-$Id: ntapi.h,v 1.16 2003/07/12 03:22:08 cph Exp $
+$Id: ntapi.h,v 1.17 2004/12/20 04:36:44 cph Exp $
-Copyright 1997,1999,2000,2002,2003 Massachusetts Institute of Technology
+Copyright 1997,1999,2000,2002,2003,2004 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
apicall_RegSetValueEx,
apicall_RemoveDirectory,
apicall_SetCurrentDirectory,
+ apicall_SetEndOfFile,
apicall_SetFileAttributes,
apicall_SetFilePointer,
apicall_SetFileTime,
"reg-set-value-ex",
"remove-directory",
"set-current-directory",
+ "set-end-of-file",
"set-file-attributes",
"set-file-pointer",
"set-file-time",
/* -*-C-*-
-$Id: ntfile.c,v 1.15 2003/02/14 18:28:20 cph Exp $
+$Id: ntfile.c,v 1.16 2004/12/20 04:36:53 cph Exp $
-Copyright (c) 1992-1999 Massachusetts Institute of Technology
+Copyright 1993,1996,1997,1998,2004 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
if (old_position != ((DWORD) position))
error_external_return ();
}
+
+void
+OS_file_truncate (Tchannel channel, off_t length)
+{
+ OS_file_set_position (channel, length);
+ STD_BOOL_API_CALL (SetEndOfFile, (CHANNEL_HANDLE (channel)));
+}
/* -*-C-*-
-$Id: osfile.h,v 1.5 2003/02/14 18:28:22 cph Exp $
+$Id: osfile.h,v 1.6 2004/12/20 04:37:01 cph Exp $
-Copyright (c) 1990, 1999 Massachusetts Institute of Technology
+Copyright 1990,1993,2004 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
extern off_t EXFUN (OS_file_length, (Tchannel channel));
extern off_t EXFUN (OS_file_position, (Tchannel channel));
extern void EXFUN (OS_file_set_position, (Tchannel channel, off_t position));
+extern void EXFUN (OS_file_truncate, (Tchannel channel, off_t length));
#endif /* SCM_OSFILE_H */
/* -*-C-*-
-$Id: prosfile.c,v 1.11 2003/02/14 18:28:23 cph Exp $
+$Id: prosfile.c,v 1.12 2004/12/20 04:37:09 cph Exp $
-Copyright (c) 1987-1999 Massachusetts Institute of Technology
+Copyright 1990,1991,1992,1993,1994,1996 Massachusetts Institute of Technology
+Copyright 2004 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
OS_file_set_position ((arg_channel (1)), (arg_nonnegative_integer (2)));
PRIMITIVE_RETURN (UNSPECIFIC);
}
+
+DEFINE_PRIMITIVE ("FILE-TRUNCATE", Prim_file_truncate, 2, 2,
+ "Set the length of CHANNEL to LENGTH.\n\
+LENGTH must be a non-negative number.")
+{
+ PRIMITIVE_HEADER (1);
+ OS_file_truncate ((arg_channel (1)), (arg_nonnegative_integer (2)));
+ PRIMITIVE_RETURN (UNSPECIFIC);
+}
/* -*-C-*-
-$Id: uxfile.c,v 1.12 2003/02/14 18:28:24 cph Exp $
+$Id: uxfile.c,v 1.13 2004/12/20 04:37:17 cph Exp $
-Copyright (c) 1990-2000 Massachusetts Institute of Technology
+Copyright 1990,1991,1993,1997,2000,2004 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
if (result != position)
error_external_return ();
}
+
+void
+DEFUN (OS_file_truncate, (channel, length),
+ Tchannel channel AND
+ off_t length)
+{
+ STD_VOID_SYSTEM_CALL
+ (syscall_ftruncate,
+ (UX_ftruncate ((CHANNEL_DESCRIPTOR (channel)), length)));
+}