home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_04 / 1104106a < prev    next >
Text File  |  1993-01-30  |  1KB  |  52 lines

  1. #include <iostream.h>
  2. #include "int_file.hpp"
  3. #include "boolean.hpp"
  4. #include "program.hpp"
  5. main()
  6.      {
  7.      Internal_File old_file;
  8.      Internal_File new_file;
  9.      Internal_ByteArray buffer(100);
  10.      Internal_ByteSize bytes;
  11.      Boolean done;
  12.      old_file.open(FileName("abc.dat"));
  13.      if (old_file.error() == Internal_File::No_error)
  14.           {
  15.           cout << "Unable to open file abc.dat";
  16.           program_exit(Failure);
  17.           }
  18.      new_file.create(FileName("def.dat"));
  19.      if (new_file.error() == Internal_File::No_error)
  20.           {
  21.           cout << "Unable to open for writing def.dat";
  22.           program_exit(Failure);
  23.           }
  24.      // Copy the files  
  25.      do 
  26.           {
  27.           old_file.read(buffer);
  28.           switch(old_file.error())
  29.                {
  30.           case Internal_File::No_error:
  31.                done = False;
  32.                break;
  33.           case Internal_File::End_of_file:
  34.                done = True;
  35.                break;
  36.           default:
  37.                cout << "Error in reading";
  38.                done = True;
  39.                break;
  40.                }
  41.           new_file.write(buffer);
  42.           if (new_file.error() != Internal_File::No_error) 
  43.                {
  44.                cout << "Error in writing";
  45.                done = True;
  46.                break;
  47.                }
  48.           } while (!done);
  49.      old_file.close();
  50.      new_file.close();
  51.      }
  52.