files.txi 2.8 KB
Newer Older
1 2 3
@node Files
@section Files

4 5 6 7 8
* Files - Dictionary::
* Files - C Reference::
@end menu

@node Files - Dictionary
@subsection Dictionary
11 12 13

@lspindex directory
@defun directory pathspec

This function does not have any additional arguments other than the ones described in ANSI @bibcite{ANSI}. To list files and directories, it follows the rules for matching pathnames described in @ref{Filenames - Wild pathnames and matching}. In short, you have the following practical examples:
16 17

@float Table, tab:examples-using-directory
@caption{Examples of using @code{directory}}
19 20 21 22 23 24 25 26
@multitable @columnfractions .25 .75
@headitem Argument @tab Meaning
@item @code{"/home/jlr/*.*"} @tab List all files in directory @code{/home/jlr/} Note that it lists only files, not directories!
@item @code{"/home/jlr/*"} @tab Same as before, but only files without type.
@item @code{"/home/jlr/*/"} @tab List all directories contained in @code{/home/jlr/}. Nested directories are not navigated.
@item @code{"/home/jlr/**/*.*"} @tab List all files in all directories contained in @code{/home/jlr/}, recursively. Nested directories are navigated.
@end multitable
@end float
27 28 29 30 31 32 33 34 35 36 37 38 39
@end defun

@defun rename-file filespec new-name &key (if-exists :error)

In addition to the arguments described in ANSI @bibcite{ANSI}, the @code{rename-file} function in ECL has an @code{:if-exists} keyword argument that specifies what happens when a file with the new name already exists. Valid values of this argument are:

@multitable @columnfractions .25 .75
@headitem Argument @tab Behaviour of the @code{rename-file} function
@item @code{:error} @tab Signal an error
@item @code{:supersede}, @code{t} @tab Overwrite the existing file
@item @code{nil} @tab Don't overwrite the existing file, don't signal an error
@end multitable
@end defun

@node Files - C Reference
@subsection C Reference
43 44

@subsubsection ANSI Dictionary
45 46 47 48 49 50 51 52 53 54 55
Common Lisp and C equivalence

@multitable @columnfractions .3 .7
@headitem Lisp symbol @tab C function
@item @clhs{f_del_fi.htm,delete-file} @tab cl_object cl_delete_file(cl_object filespec)
@item @clhs{f_dir.htm,directory} @tab cl_object cl_directory(cl_narg narg, cl_object pathspec, ...)
@item @clhs{f_ensu_1.htm,ensure-directories-exist} @tab cl_object cl_ensure_directories_exist(cl_narg narg, cl_object pathspec, ...)
@item @clhs{f_file_a.htm,file-author} @tab cl_object cl_file_author(cl_object pathspec)
@item @clhs{f_file_e.htm,file-error-pathname} @tab [Only in Common Lisp]
@item @clhs{f_file_w.htm,file-write-date} @tab cl_object cl_file_write_date(cl_object pathspec)
@item @clhs{f_probe_.htm,probe-file} @tab cl_object cl_probe_file(cl_object pathspec)
@item @clhs{f_rn_fil.htm,rename-file} @tab cl_object cl_rename_file(cl_narg narg, cl_object filespec, cl_object new_name, ...)
57 58
@item @clhs{f_tn.htm,truename} @tab cl_object cl_truename(cl_object filespec)
@end multitable