Copyright (C) 1994, Digital Equipment Corp.
The
UnixUtils
interface contain assorted procedures that
access the Unix file system. These calls should eventually
be subsumed by the Modula-3 core libraries.
INTERFACEUnixUtils ; IMPORT TextList, Ctypes, Utypes; PROCEDURE Directory (dirname: TEXT): TextList.T RAISES {Error};
Return a list of all the files in the named directory. Raise an exception ifopendir(3)
returnsNULL
, which happens ``if the specified filename can not be accessed, or if insufficient memory is available to open the directory file.''
EXCEPTION Error(TEXT);
The argument to theError
exception isstrerror(errno)
converted toTEXT
.
PROCEDURE IsDirectory (pathname: TEXT): BOOLEAN;
Does pathname
specify a directory?
PROCEDURE ProbeFile (file: TEXT; error: BOOLEAN): BOOLEAN RAISES {Error};
Iffile
exists, return TRUE. Otherwise, iferror
is TRUE, raise an exception. Otherwise return FALSE.
TYPE Seconds = Utypes.time_t;
This is an INTEGER
representing the number of seconds since
January 1, 1970 GMT.
PROCEDURE FileModifyTime (file: TEXT): Seconds;
When wasfile
last modified? Return thest_mtime
from the call tostat(2)
.
PROCEDURE GetWD (): TEXT RAISES {Error};
Return the value of callinggetwd(3)
, raising the exception ifgetwd
reports any problems.
TYPE AccessMode = {Execute, Write, Read}; PROCEDURE Accessible (file: TEXT; modes := SET OF AccessMode {}): BOOLEAN;
Test whetherfile
can be accessed according tomodes
. For details, see the manpage foraccess(2)
. The default value ofmodes
will test whether the directories leading to the file can be searched and whether the file exists.
<* EXTERNAL *> PROCEDURE access (path: Ctypes.char_star; mode: Ctypes.int): Ctypes.int; END UnixUtils.