file-contents

Function

Package: excl

Arguments: pathname &rest open-arguments

This function, new in release 6.0, returns a vector containing the contents of the file specified by pathname (which can be a string naming a file or a pathname object). The open-arguments should be keyword/value pairs suitable to be passed to the function open (but :direction is not accepted).

The element-type argument to open and accepted by this function specifies the type of vector that will be created (which will be upgraded-array-element-type applied to the specified element-type). If element-type is not specified, it defaults to character and the result is a string. For a byte array containing the file contents, specify (unsigned-byte 8). Basically, the function is intended for element-types character and (unsigned-byte 8). Specifying other element types will work but may produce an unspecialized array (element-type t) which would not be suitable as data when setf'ing this function.

The behavior if the file specified by pathname does not exist is determined by the if-does-not-exist argument (to open and thus to this function). For this function, that argument defaults to nil so nil is returned if the file does not exist and if-does-not-exist is unspecified.

This function is setf'able. The setf function has argument list

Arguments: vector pathname &rest open-arguments

The standard setf form is, of course:

(setf (file-contents pathname) vector)

The setf function also accepts keyword/value pairs suitable to be passed to the function open, but :direction and :element-type are not accepted. The element-type passed to open is the array-element-type of vector. Warning: if the element-type of the vector is not suitable as an element-type for open, the call to open will fail. t is not suitable as an element-type to open. character and (unsigned-byte 8) are both, of course, suitable.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.