Go to the documentation of this file.00001
00002
00003
00004
00005
00008
00009 #ifndef largeFileFunctions_H_
00010 #define largeFileFunctions_H_
00011
00012 #include "lgrUtil.h"
00013
00014 #include <stddef.h>
00015 #include <vlutil/vlMachineTypes.h>
00016
00017 class DtFilename;
00018
00019 namespace MAKLogger
00020 {
00021 typedef int DtFileDesc;
00022
00027 class DT_DLL_LGRUTIL DtLargeFileFunctions
00028 {
00029 public:
00030
00034 static DtFileDesc openForReading(const DtFilename& filename);
00035
00039 static DtFileDesc openForWriting(const DtFilename& filename, bool truncate = true);
00040
00044 static DtFileDesc openForReadingAndWriting(DtFilename filename,
00045 bool truncate = false);
00046
00050 static bool close(DtFileDesc);
00051
00053 static DtInt64 size(DtFileDesc);
00054
00056 static DtInt64 tell(DtFileDesc);
00057
00060 static DtInt64 seekCurrent(DtFileDesc,DtInt64);
00061
00064 static DtInt64 seekEnd(DtFileDesc,DtInt64);
00065
00068 static DtInt64 seekSet(DtFileDesc,DtInt64);
00069
00075 static size_t read(DtFileDesc,void* buffer,size_t bytesToRead);
00076
00083 template <typename T>
00084 static bool readStruct(DtFileDesc fd,T& structObject)
00085 {
00086 size_t desiredSize = sizeof(T);
00087 size_t readSize = DtLargeFileFunctions::read(fd,&structObject,desiredSize);
00088 return readSize == desiredSize;
00089 }
00090
00097 static char* readBytes(DtFileDesc,size_t bytesToRead,size_t& totalBytesRead);
00098
00103 static size_t write(DtFileDesc,const void* buffer,size_t bytesToWrite);
00104
00111 template <typename T>
00112 static bool writeStruct(DtFileDesc fd,const T& structObject)
00113 {
00114 size_t desiredSize = sizeof(T);
00115 size_t writeSize = DtLargeFileFunctions::write(fd,&structObject,desiredSize);
00116 return writeSize == desiredSize;
00117 }
00118
00119 };
00120
00121 }
00122
00123 #endif