Next: filenameclass
Up: simlib
Previous: character_io
DirectoryFile
NAME
directoryfile - rouitnes to read directory filenames
DESCRIPTION
DirectoryFile is used to read the entries in a file-system
directory. The File is open before access. Entries are
returend one by one.
EXAMPLE
external class DirectoryFile;
ref(DirectoryFile) Directory;
text t; integer i;
Directory:- new DirectoryFile(SomeName);
if not Directory.open the
error( Can't open :"& SomeName)"
else
begin
while Directory.NextEntry do
begin
outtext(Directory.EntryName); outimage;
end;
Directory.close;
end;
AUTHOR
Boris Magnusson, Lund University.
SEE ALSO
FileStatus - routines to access Unix filesystem info about a
file.
DETAILED INTERFACE
class DirectoryFile(FileName);
text FileName;
After succefully opened, the filename of a directory can be
read sequentially by calling NextEntry to advance and
EntryName to access the name of the file.
This class only reports the name of the files in a
directory. See the class FileStatus for getting information
about the indiviual files.
Supers: -
Kind: Instantiable
Init: DF :- new DirectoryFile("aDirectoryFilename") ;
Sequencing: (Open (NextEntry EntryName)* Close)*
OPERATIONS
Open
Boolean procedure Open;
Return True if the file is a directory and can be opened for
reading.
Close
Boolean procedure Close;
Returns true if the file could be closed succesfully.
NextEntry
Boolean procedure NextEntry;
Advances to the next entry in the directory. Returns True if
there was yet another entry and false when there are no more
entries.
Entryname
text procedure Entryname;
Returns the "filename" of the current Entry in the
directory.