/* FILES : Routines for playing with files UTILITY Lawrence Updated: 11 September 81 */ %%% FILES requires no other modules % Check to see if a file exists and provide % an error message if it doesn't check_exists(File) :- exists(File), !. check_exists(File) :- ttynl, display('! File: '), display(File), display(' does not exist.'), ttynl, fail. % Open a file, checking that it exists open(File) :- check_exists(File), see(File). % Open a file and return current file open(Old,File) :- seeing(Old), open(File). % Close file and see old file again close(File,Old) :- close(File), see(Old). % Delete a file (note that rename requires that % the file be open) % ?? Probably doesn't in EMAS Prolog delete(File) :- open(Old,File), rename(File,[]), see(Old).