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

mxcpcStreamFile.cpp

00001 //           ///          //
00002 //          /////        ////
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mxcpcStreamFile.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 <mxcpcStreamFile.h>
00018 #include <mxcpc_exceptions.h>
00019 
00020 #ifdef WIN32
00021 #include <io.h>
00022 #else
00023 #include <unistd.h>
00024 #endif
00025 #include <fcntl.h> 
00026 
00027 
00028 
00029 mxcpcStreamFile::mxcpcStreamFile(const char *filename) {
00030 
00031   InFile = open(filename, O_RDONLY);
00032   if(InFile == -1) throw mxcpcIOFailure();
00033 
00034   StillUp = true;
00035 }
00036 
00037 
00038 mxcpcStreamFile::~mxcpcStreamFile() {
00039 
00040   close(InFile);
00041 }
00042 
00043 
00044 
00045 int mxcpcStreamFile::fetchBytes(unsigned char *buffer, int num) {
00046 
00047   int actually_read;
00048   
00049   if(!StillUp) return(0);
00050   
00051   actually_read = read(InFile, buffer, num);
00052    
00053   if(actually_read <= 0) {
00054   
00055     StillUp = false;
00056     return(0);
00057   }
00058   
00059   return(actually_read);
00060 }

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