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

mxcpcStreamFileDumper.cpp

00001 //           ///          //
00002 //          /////        ////
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mxcpcStreamFileDumper.cpp,v $  
00005 //       ///       XXX       ///     $Revision: 1.2 $
00006 //      ///      XXX XXX      ///     $Date: 2005/08/09 13:57:26 $
00007 //     ////    XXX     XXX    ////     $Author: cvs-steve $
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems ///////////////////////////////////////////////
00011 
00012 // Copyright (c) 2005, MOBOTIX AG.
00013 // This software is made available under the BSD licence. Please refer 
00014 // to the file LICENCE.TXT contained in this distribution for details.
00015 
00016 
00017 #include <mxcpcStreamFileDumper.h>
00018 #include <mxcpc_exceptions.h>
00019 
00020 
00021 
00022 mxcpcStreamFileDumper::mxcpcStreamFileDumper(mxcpcStreamSource *stream_source,
00023                                              const char *filename) {
00024   
00025   Source = stream_source;
00026 
00027   OutFile = 0;
00028   
00029   try {
00030     
00031     OutFile = std::fopen(filename, "w");
00032     if(!OutFile) throw mxcpcIOFailure();
00033     
00034   } catch(std::exception &e) {
00035     
00036       MXCPC_RETHROW_UNHANDLED_EXCEPTION(e);
00037       
00038       if(OutFile) std::fclose(OutFile);
00039       
00040       throw;
00041     }
00042 }
00043 
00044 
00045 mxcpcStreamFileDumper::~mxcpcStreamFileDumper() {
00046 
00047   delete Source;
00048 
00049   std::fclose(OutFile);
00050 }
00051 
00052 
00053 
00054 int mxcpcStreamFileDumper::fetchBytes(unsigned char *buffer, int num) {
00055 
00056   int actually_fetched;
00057 
00058   actually_fetched = Source->fetchBytes(buffer, num);
00059   
00060   if(actually_fetched) {
00061   
00062     fwrite(buffer, actually_fetched, 1, OutFile);
00063   }
00064   
00065   return(actually_fetched);
00066 }

Generated on Mon Aug 15 03:39:30 2005 for mxcpc by  doxygen 1.4.2-20050421