Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "DcRetrieveFile.h"
00027
00028 CdcFileCacher CdcRetrieveFile::oFileCache;
00029
00030 CdcBuffer CdcRetrieveFile::GetData () throw (CdcException)
00031 {
00032 if (oFileAttrib.IsFileFound () == false)
00033 throw (CdcExceptionFile (CdcString ("Cannot find the file - ") +
00034 oFileAttrib.GetURL (), DC_FILE_NOT_FOUND_EXP));
00035 CdcBuffer data;
00036
00037 if (oFileAttrib.IsNotToCache () == false &&
00038 oFileCache.GetFile (oFileAttrib.GetFullName (),
00039 oFileAttrib.GetLastModified (), data) == true)
00040 return data;
00041
00042 char temp [1024];
00043 int ret, mode = ios::in | ios::binary;
00044
00045 if (oFile.is_open () == 0)
00046 oFile.open (oFileAttrib.GetFullName ().GetBuffer (), mode);
00047 if (oFile.is_open () == 0)
00048 throw (CdcExceptionFile (CdcString ("Cannot open the file - ") +
00049 oFileAttrib.GetURL (), DC_FILE_NOT_FOUND_EXP));
00050
00051 while (oFile.eof () == 0)
00052 {
00053 oFile.read (temp, 1000);
00054 ret = oFile.gcount ();
00055 data.Append (temp, ret);
00056 }
00057 oFile.close ();
00058
00059 if (oFileAttrib.IsNotToCache () == false)
00060 oFileCache.PutFile (oFileAttrib.GetFullName (),
00061 oFileAttrib.GetLastModified (), data);
00062 return data;
00063 }