Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

TestFPFile.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Done on Fri Aug  1 11:13:49 PDT 1997 by heydon
00020 // Last modified on Fri Jul 16 17:11:00 EDT 2004 by ken@xorian.net  
00021 //      modified on Wed Sep  6 18:35:29 PDT 2000 by mann  
00022 //      modified on Fri Aug  1 15:37:53 PDT 1997 by heydon
00023 
00024 /* Syntax: TestFPFile filename
00025 
00026    Open the file named "filename", fingerprint its contents, close the
00027    file, and print the resulting fingerprint.
00028 */
00029 
00030 #include <Basics.H>
00031 #include <FS.H>
00032 #include <FP.H>
00033 
00034 using std::cerr;
00035 using std::cout;
00036 using std::endl;
00037 using std::ifstream;
00038 
00039 void Syntax(char *msg) throw ()
00040 {
00041     cerr << "Error: " << msg << endl;
00042     cerr << "Syntax: TestFPFile filename" << endl;
00043     exit(1);
00044 }
00045 
00046 void DoWork(const Text &fname, /*INOUT*/ FP::Tag &fp) throw (FS::Failure)
00047 {
00048     ifstream ifs;
00049     FS::OpenReadOnly(fname, /*OUT*/ ifs);
00050     FP::FileContents(ifs, /*INOUT*/ fp);
00051     FS::Close(ifs);
00052 }
00053 
00054 int main(int argc, char *argv[])
00055 {
00056     if (argc != 2) Syntax("incorrect number of arguments");
00057     Text filename(argv[1]);
00058     FP::Tag fp("");
00059     try {
00060         DoWork(filename, /*INOUT*/ fp);
00061         cout << fp << endl;
00062     }
00063     catch (const FS::Failure &f) {
00064         cerr << f;
00065     }
00066     return 0;
00067 }

Generated on Mon May 8 00:48:41 2006 for Vesta by  doxygen 1.4.2