📄 unit-files.html
字号:
<html><head><title>CHICKEN User's Manual - Unit files</title></head><body><p> </p><a name="unit-files"></a><h1>Unit files</h1><p>This unit contains file- and pathname-oriented procedures. It uses the <tt>regex</tt> unit.</p><a name="pathname-operations"></a><h2>Pathname operations</h2><a name="absolute-pathname"></a><h3>absolute-pathname?</h3><pre>[procedure] (absolute-pathname? PATHNAME)</pre><p>Returns <tt>#t</tt> if the string <tt>PATHNAME</tt> names an absolute pathname, and returns <tt>#f</tt> otherwise.</p><a name="decompose-pathname"></a><h3>decompose-pathname</h3><pre>[procedure] (decompose-pathname PATHNAME)</pre><p>Returns three values: the directory-, filename- and extension-components of the file named by the string <tt>PATHNAME</tt>. For any component that is not contained in <tt>PATHNAME</tt>, <tt>#f</tt> is returned.</p><a name="make-pathname"></a><h3>make-pathname</h3><a name="make-absolute-pathname"></a><h3>make-absolute-pathname</h3><pre>[procedure] (make-pathname DIRECTORY FILENAME [EXTENSION [SEPARATOR]])[procedure] (make-absolute-pathname DIRECTORY FILENAME [EXTENSION [SEPARATOR]])</pre><p>Returns a string that names the file with the components <tt>DIRECTORY, FILENAME</tt> and (optionally) <tt>EXTENSION</tt> with <tt>SEPARATOR</tt> being the directory separation indicator (usually <tt>/</tt> on UNIX systems and <tt>\</tt> on Windows, defaulting to whatever platform this is running on). <tt>DIRECTORY</tt> can be <tt>#f</tt> (meaning no directory component), a string or a list of strings. <tt>FILENAME</tt> and <tt>EXTENSION</tt> should be strings or <tt>#f</tt>. <tt>make-absolute-pathname</tt> returns always an absolute pathname.</p><a name="pathname-directory"></a><h3>pathname-directory</h3><pre>[procedure] (pathname-directory PATHNAME)</pre><a name="pathname-file"></a><h3>pathname-file</h3><pre>[procedure] (pathname-file PATHNAME)</pre><a name="pathname-extension"></a><h3>pathname-extension</h3><pre>[procedure] (pathname-extension PATHNAME)</pre><p>Accessors for the components of <tt>PATHNAME</tt>. If the pathname does not contain the accessed component, then <tt>#f</tt> is returned.</p><a name="pathname-replace-directory"></a><h3>pathname-replace-directory</h3><pre>[procedure] (pathname-replace-directory PATHNAME DIRECTORY)</pre><a name="pathname-replace-file"></a><h3>pathname-replace-file</h3><pre>[procedure] (pathname-replace-file PATHNAME FILENAME)</pre><a name="pathname-replace-extension"></a><h3>pathname-replace-extension</h3><pre>[procedure] (pathname-replace-extension PATHNAME EXTENSION)</pre><p>Return a new pathname with the specified component of <tt>PATHNAME</tt> replaced by a new value.</p><a name="pathname-strip-directory"></a><h3>pathname-strip-directory</h3><pre>[procedure] (pathname-strip-directory PATHNAME)</pre><a name="pathname-strip-extension"></a><h3>pathname-strip-extension</h3><pre>[procedure] (pathname-strip-extension PATHNAME)</pre><p>Return a new pathname with the specified component of <tt>PATHNAME</tt> stripped.</p><a name="directory-null"></a><h3>directory-null?</h3><pre>[procedure] (directory-null? DIRECTORY)</pre><p>Does the <tt>DIRECTORY</tt> consist only of path separators and the period?</p><p><tt>DIRECTORY</tt> may be a string or a list of strings.</p><a name="temporary-files"></a><h2>Temporary files</h2><a name="create-temporary-file"></a><h3>create-temporary-file</h3><pre>[procedure] (create-temporary-file [EXTENSION])</pre><p>Creates an empty temporary file and returns its pathname. If <tt>EXTENSION</tt> is not given, then <tt>.tmp</tt> is used. If the environment variable <tt>TMPDIR, TEMP</tt> or <tt>TMP</tt> is set, then the pathname names a file in that directory.</p><a name="deleting-a-file-without-signalling-an-error"></a><h2>Deleting a file without signalling an error</h2><a name="delete-file"></a><h3>delete-file*</h3><pre>[procedure] (delete-file* FILENAME)</pre><p>If the file <tt>FILENAME</tt> exists, it is deleted and <tt>#t</tt> is returned. If the file does not exist, nothing happens and <tt>#f</tt> is returned.</p><a name="file-move-copy"></a><h2>File move/copy</h2><a name="file-copy"></a><h3>file-copy</h3><pre>[procedure] (file-copy ORIGFILE NEWFILE #!optional CLOBBER BLOCKSIZE)</pre><p>Copies <tt>ORIGFILE</tt> (a string denoting some filename) to <tt>NEWFILE</tt>, <tt>BLOCKSIZE</tt> bytes at a time. <tt>BLOCKSIZE</tt> defaults to 1024, and must be a positive integer. Returns the number of bytes copied on success, or errors on failure. <tt>CLOBBER</tt> determines the behaviour of <tt>file-copy</tt> when <tt>NEWFILE</tt> is already extant. When set to <tt>#f</tt> (default), an error is signalled. When set to any other value, <tt>NEWFILE</tt> is overwritten. <tt>file-copy</tt> will work across filesystems and devices and is not platform-dependent.</p><a name="file-move"></a><h3>file-move</h3><pre>[procedure] (file-move ORIGFILE NEWFILE #!optional CLOBBER BLOCKSIZE)</pre><p>Moves <tt>ORIGFILE</tt> (a string denoting some filename) to <tt>NEWFILE</tt>, with the same semantics as <tt>file-copy</tt>, above. <tt>file-move</tt> is safe across filesystems and devices (unlike <tt>file-rename</tt>). It is possible for an error to be signalled despite partial success if <tt>NEWFILE</tt> could be created and fully written but removing <tt>ORIGFILE</tt> fails.</p><p>Previous: <a href="unit-ports.html" class="internal">Unit ports</a></p><p>Next: <a href="unit-extras.html" class="internal">Unit extras</a></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -