本文整理汇总了C++中DiskFile::FileSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DiskFile::FileSize方法的具体用法?C++ DiskFile::FileSize怎么用?C++ DiskFile::FileSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiskFile
的用法示例。
在下文中一共展示了DiskFile::FileSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: offsetof
bool Par1Repairer::LoadRecoveryFile(string filename) {
// Skip the file if it has already been processed
if (diskfilemap.Find(filename) != 0) {
return true;
}
DiskFile *diskfile = new DiskFile;
// Open the file
if (!diskfile->Open(filename)) {
// If we could not open the file, ignore the error and
// proceed to the next file
delete diskfile;
return true;
}
if (noiselevel > CommandLine::nlSilent) {
string path;
string name;
DiskFile::SplitFilename(filename, path, name);
cout << "Loading \"" << name << "\"." << endl;
}
parlist.push_back(filename);
bool havevolume = false;
u32 volumenumber = 0;
// How big is the file
u64 filesize = diskfile->FileSize();
if (filesize >= sizeof(PAR1FILEHEADER)) {
// Allocate a buffer to read data into
size_t buffersize = (size_t)min((u64)1048576, filesize);
u8 *buffer = new u8[buffersize];
do {
PAR1FILEHEADER fileheader;
if (!diskfile->Read(0, &fileheader, sizeof(fileheader)))
break;
// Is this really a PAR file?
if (fileheader.magic != par1_magic)
break;
// Is the version number correct?
if (fileheader.fileversion != 0x00010000)
break;
ignore16kfilehash = (fileheader.programversion == smartpar11);
// Prepare to carry out MD5 Hash check of the Control Hash
MD5Context context;
u64 offset = offsetof(PAR1FILEHEADER, sethash);
// Process until the end of the file is reached
while (offset < filesize) {
// How much data should we read?
size_t want = (size_t)min((u64)buffersize, filesize-offset);
if (!diskfile->Read(offset, buffer, want))
break;
context.Update(buffer, want);
offset += want;
}
// Did we read the whole file
if (offset < filesize)
break;
// Compute the hash value
MD5Hash hash;
context.Final(hash);
// Is it correct?
if (hash != fileheader.controlhash)
break;
// Check that the volume number is ok
if (fileheader.volumenumber >= 256)
break;
// Are there any files?
if (fileheader.numberoffiles == 0 ||
fileheader.filelistoffset < sizeof(PAR1FILEHEADER) ||
fileheader.filelistsize == 0)
break;
// Verify that the file list and data offsets are ok
if ((fileheader.filelistoffset + fileheader.filelistsize > filesize)
||
(fileheader.datasize && (fileheader.dataoffset < sizeof(fileheader) || fileheader.dataoffset + fileheader.datasize > filesize))
||
(fileheader.datasize && ((fileheader.filelistoffset <= fileheader.dataoffset && fileheader.dataoffset < fileheader.filelistoffset+fileheader.filelistsize) || (fileheader.dataoffset <= fileheader.filelistoffset && fileheader.filelistoffset < fileheader.dataoffset + fileheader.datasize))))
break;
// Check the size of the file list
if (fileheader.filelistsize > 200000)
break;
//.........这里部分代码省略.........