7 if (
fIn.open(QIODevice::ReadOnly) ==
false) {
8 throw FileBufferException(
"Cannot open the file: " + path);
12 std::cerr <<
fIn.errorString().toStdString() << std::endl;
16 this->
mappedSize = (readableSize > maxSize) ? maxSize : readableSize;
44 if (fIn.open(QIODevice::ReadOnly) ==
false) {
55 bufsize_t allocSize = (readableSize < minBufSize) ? minBufSize : readableSize;
64 if (!allowTruncate)
throw;
67 }
while(!bufferedFile && allocSize);
69 char *content = (
char*) bufferedFile->
getContent();
77 offset_t maxOffset = contentSize - 1;
79 while (
offset_t(fIn.pos()) < maxOffset) {
81 bufsize_t maxSize = contentSize - readSize;
84 readSize += fIn.read(content + readSize, maxSize);
85 if (prevOffset == fIn.pos())
break;
86 prevOffset = fIn.pos();
90 static_cast<unsigned long>(readSize)
106 if (!path.length())
return 0;
108 if (!fIn.open(QIODevice::ReadOnly))
return 0;
123 if (fOut.open(QFile::WriteOnly) ==
false) {
124 if (allowExceptions)
throw FileBufferException(
"Cannot open the file: " + path +
" for writing");
const bufsize_t FILEVIEW_MAXSIZE
const bufsize_t FILE_MAXSIZE
virtual bufsize_t getContentSize()=0
virtual BYTE * getContent()=0
static bufsize_t getReadableSize(QFile &fIn)
static bufsize_t dump(const QString &fileName, AbstractByteBuffer &buf, bool allowExceptions=false)
static ByteBuffer * read(QString &file, bufsize_t minBufSize, const bool allowTruncate)
virtual BYTE * getContent()
virtual bufsize_t getContentSize()
bufsize_t getMappableSize()
FileView(QString &fileName, bufsize_t maxSize=FILE_MAXSIZE)
bool append(dbg_level lvl, const char *format,...)