|
|
Section Intro: File Operators
File OperatorsSynopsis:There are several types of commands in Meta-HTML for dealing with files. Some of these commands operate directly on an open files, while others operate on streams (see Stream Operators), which may be connected to files or network data.
The functions allow you to Commands: Variables: More Information:
Commands such as
Execute the system function named by PATHNAME, perhaps passing it arguments ARG ... ARGN. If OUTPUT=VARNAME is supplied, then the variable referenced by VARNAME receives the output of the command. Otherwise, the resultant output is placed in the page.
If ERRORS=VARNAME is supplied, then VARNAME receives the
error output of the command. Otherwise, the resultant output is placed
in
Return the "basename" of PATHNAME. This simply returns the last component of PATHNAME. Example: <dir::basename /foo/bar/baz.dtd>produces: baz.dtd
Make PATH be absolute in the file system.
If PATH starts with a "/", then do nothing, otherwise, prefix
it with Given an empty PATH, return the full path to the directory that this page resides in. Example: <dir::canonicalize-pathname foo.mhtml>produces: /home/groups/m/me/metahtml/htdocs/documentation/manual/foo.mhtml
Copy the file named SOURCE to the file named DEST, completely replacing the contents of destination file. Returns "true" if the file was successfully copied, or the empty string otherwise. Both SOURCE and DEST are fully qualified pathnames -- they may point to anywhere in the file system, and are not directly related to web space at all. The directory containing the destination file is created if it doesn't already exist.
Create an Emacs-style backup of PATHNAME, and return the name of the backup file. No more than MAX backups may exist -- if you pass MAX as a positive integer then multiple backups up to that many will be made. The default value for MAX is infinity. If PATHNAME exists, a backup of it is made by appending "~num" to the name. If the most recent backup is within 1 hour of the existing file, no backup is made (unless FORCE is "true". Thus, we maintain some compatibility with the Emacs style of making backup files. If PATHNAME is already a backup file, nothing is done.
Produces a clickable listing of the files in WEBPATH limited to those which match REGEXP, displaying icons found in ICON-DIR. WEBPATH defaults to the directory containing this page.
REGEXP defaults to ICON-DIR defaults to /images/icons -- each file is associated with an icon file named by file extension (e.g, mhtml.gif, html.gif, etc.) Icons are only shown if SHOW-ICONS is set. Possible values for SORT-OP are:
SORT-OP defaults to
<dir::dir-table>
Return the directory part of PATHNAME. This simply returns everything but the last component of PATHNAME. Example: <dir::dirname /foo/bar/baz.dtd>produces: /foo/bar
Return the filename extension of FILENAME, without the leading period. Returns the empty string if FILENAME doesn't have an extension.
<dir::filename-extension /images/foo.gif> ==> gif <dir::filename-extension /downloads/foo.tar.gz> ==> gz <dir::filename-extension /data/file> ==>
Return FILENAME without its extension part. <dir::filename-sans-extension /www/bin/foo.lib>produces: /www/bin/foo
Return PATH, resolving any "./" or "../" found within. Example: <dir::handle-dots /foo/bar/../baz/./../below-foo>produces: /foo/below-foo
Return an array of the fully qualified pathnames in DIR which
are of type TYPE (either "
DIR defaults to the directory of the currently executing page.
Read in the contents of the file named by FILENAME and return them. If the optional variable VARNAME is given, it is the name of a binary variable to receive the contents of the file. In that case, the word "true" is returned if the file was successfully read, or the empty string otherwise.
<dir::read-file /tmp/foo.gif gifdata> ==>true <set-var hosts[]=<dir::read-file /etc/hosts>>
Write the contents of the variable named by VARNAME to the file
named by FILENAME. Returns "true" if the file was written, and
the empty string otherwise.
MODE defaults to "write-create", thus creating the file.
See
Returns a newline separated list of association lists for the files matching PATTERN. When PACKAGE-NAME is supplied, each variable in PACKAGE-NAME is the name of a file in PATHNAME, and the value of each variable is the association list for that file.
Treat the argument VAR as the name of a variable which contains
an alist produced by
Return "true" if PATHNAME is a directory, or "" if not.
Returns "true" if PATHNAME is an existing file or directory.
PATHNAME is absolute, that is to say that it is looked up in
absolute file system space, not in Web space. To find out if a file
<file-exists <thisdir>/foo>
Return "true" if FILE1 has been written more recently than FILE2. Both FILE1 and FILE2 are fully qualified pathnames.
Return an association-list containing operating system information about the file or directory named by PATH. PATHNAME must be given fully; it is not relative to Web space in any way. If the file exists and is accessible, the members of the returned association-list which are guaranteed to be present are:
In addition to the above fields, the following fields appear on Unix based systems:
Example: <dump-alist <get-file-properties />>produces:
Dump of package: ^
Create all of the directories in PATH (a fully qualified path to a directory) if they are not already present. If MODE-STRING is present, the final directory is set to that mode using the chmod() command.
Return the fully qualified path to the program which would be executed by CGI-EXEC for BASENAME. Example: <path::find-executable ls> ==> /bin/ls
Both ` STEM.lib' and ` STEM.mhtml' are searched for -- <require> loads the one which is newer. In either case, if a function named ` .LIBINIT' is defined after the load, then that function is executed with 0 arguments, and the function definition is then removed.
If the variable
Create a named pipe on unix systems that support named pipes. The pipe is named FILENAME and is created with the access mode specified by MODE-BITS, an octal permissions mask. MODE-BITS defaults to 0666 if not specified. After a named pipe is created, it can be written to and read from in the normal manner for writing and reading file streams. UNIX::MKFIFO returns "true" if the named pipe could be created, or the empty string if not. In the case of an error, the human readable text of the error message appears in SYSTEM-ERROR-OUTPUT.
Returns "true" if the specified DOCUMENT-PATH exists with "/" being equal to the document root directory.
Edit Section
![]() The META-HTML Reference Manual V2.0 Copyright © 1995, 1998, Brian J. Fox Found a bug? Send mail to bug-manual@metahtml.org |