#include "RESOLVE_Foundation.h" program_body main () { object Boolean finished; object Character_IStream input; object Character_OStream output; input.Open_External (""); output.Open_External (""); while (not finished) { object Text path; output << "\n\nEnter a path name, or return to quit: "; input >> path; finished = (path.Length () == 0); if (not finished) { if (File_Is_A_Directory (path)) { output << "\n" << path << "\nis a directory."; } else if (File_Is_Readable (path)) { object Character_IStream infile; // Read and echo file, character by character output << "\n\n*** Contents of file " << path << "\n(read character by character):\n"; infile.Open_External (path); while (not infile.At_EOS ()) { object Character ch; infile.Read (ch); output << ch; } infile.Close_External (); // Read and echo file, line by line (adding a newline // at the end of output if the file does not end in // one) output << "\n\n*** Contents of file " << path << "\n(read line by line):\n"; infile.Open_External (path); while (not infile.At_EOS ()) { object Text t; infile >> t; output << t << '\n'; } infile.Close_External (); } else { output << "\nIt is not the case that " << path << "\nexists and is readable."; } } } input.Close_External (); output.Close_External (); }