next up previous
Next: UnixCmdLineClass Up: simlib Previous: FileStatus

FileUtil


     NAME
	  fileutil - basic routines to interface to the	filesytem
	  utilities

     DESCRIPTION
	  This class contains a	few routines to	manage files. The
	  routines placed here are resonably general and should	be
	  possible to implement	in most	operating systems.

     EXAMPLE
	       ref(Fileutil) Filesystem;
	       Text Filename;
	       Filesystem:-new Fileutil;
	       if Filesystem.Exist(Filename) then
		    Delete(Filename);

     AUTHOR
	  Boris	Magnusson, Lund	University.

     SEE ALSO
	  FileStatus - routines	to access Unix filesystem info about a
	  file.

     DETAILED INTERFACE
	     class FileUtil;
	  OS related operations	on Simula files	that can  not,	or  is
	  not  convenient  to  do  through  the	 Simula	 File 'Access'
	  function.

	  Operations  placed  in  this	class  are  intended   to   be
	  'portable' and implementable in most operating systems.

	  Supers: -
	  Kind:	Instantiable
	  Init:	-
	  Sequencing: (Exist/Delete/Rename/FileNumber)*

     OPERATIONS
     Exist
	     Boolean procedure Exist(T);
	     text T; ! Full name of the	file.;
	  Return true if a file	exist. The parameter is	 the  filename
	  of  the  file.   Note: This routine returns true even	if the
	  file can not be opened because of access priviliges.

     Delete
	     Boolean procedure Delete(t);
	     text t; ! Full name of the	file.;
	  This procedure deletes a file	if it exists. Returns false if
	  the  file  did  not  exist  or  couldn't  be deleted (access
	  priviliges).

     Rename
	     Boolean procedure Rename(told,tnew);
	     text told;	! Full filename	as the file is currently
	     known.;
	     text tnew;	! Full,	new, name the file will	be known as.;
	  This procedure renames a file.  Returns false	if it couldn't
	  be  done.  Notice  that  files  can  not  be	moved  between
	  filesystems through renaming.

     FileNumber
	     integer procedure FileNumber(f);
	     ref(file) f; ! Open Simula	file.;
	  This procedure returns the Unix filenumber (0,1,2,..)	of  an
	  open Simula file.  Returns -1	if it is not open. Useful when
	  interfacing to Unix system software.