本文整理汇总了C++中MemChunk::hasData方法的典型用法代码示例。如果您正苦于以下问题:C++ MemChunk::hasData方法的具体用法?C++ MemChunk::hasData怎么用?C++ MemChunk::hasData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemChunk
的用法示例。
在下文中一共展示了MemChunk::hasData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
/* ResArchive::open
* Reads res format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool ResArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Read res header
uint32_t dir_size = 0;
uint32_t dir_offset = 0;
char magic[4] = "";
mc.seek(0, SEEK_SET);
mc.read(&magic, 4); // "Res!"
mc.read(&dir_offset, 4); // Offset to directory
mc.read(&dir_size, 4); // No. of lumps in res
// Byteswap values for big endian if needed
dir_size = wxINT32_SWAP_ON_BE(dir_size);
dir_offset = wxINT32_SWAP_ON_BE(dir_offset);
// Check the header
if (magic[0] != 'R' || magic[1] != 'e' || magic[2] != 's' || magic[3] != '!')
{
LOG_MESSAGE(1, "ResArchive::openFile: File %s has invalid header", filename);
Global::error = "Invalid res header";
return false;
}
if (dir_size % RESDIRENTRYSIZE)
{
LOG_MESSAGE(1, "ResArchive::openFile: File %s has invalid directory size", filename);
Global::error = "Invalid res directory size";
return false;
}
uint32_t num_lumps = dir_size / RESDIRENTRYSIZE;
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Read the directory
mc.seek(dir_offset, SEEK_SET);
UI::setSplashProgressMessage("Reading res archive data");
if (!readDirectory(mc, dir_offset, num_lumps, getRoot()))
return false;
// Detect maps (will detect map entry types)
UI::setSplashProgressMessage("Detecting maps");
detectMaps();
// Setup variables
setMuted(false);
setModified(false);
announce("opened");
UI::setSplashProgressMessage("");
return true;
}
示例2: importMemChunk
/* ArchiveEntry::importMemChunk
* Imports data from a MemChunk object into the entry, resizing it
* and clearing any currently existing data.
* Returns false if the MemChunk has no data, or true otherwise.
*******************************************************************/
bool ArchiveEntry::importMemChunk(MemChunk& mc)
{
// Check that the given MemChunk has data
if (mc.hasData())
{
// Copy the data from the MemChunk into the entry
return importMem(mc.getData(), mc.getSize());
}
else
return false;
}
示例3: open
/* DatArchive::open
* Reads wad format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool DatArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
const uint8_t* mcdata = mc.getData();
// Read dat header
mc.seek(0, SEEK_SET);
uint16_t num_lumps;
uint32_t dir_offset, unknown;
mc.read(&num_lumps, 2); // Size
mc.read(&dir_offset, 4); // Directory offset
mc.read(&unknown, 4); // Unknown value
num_lumps = wxINT16_SWAP_ON_BE(num_lumps);
dir_offset = wxINT32_SWAP_ON_BE(dir_offset);
unknown = wxINT32_SWAP_ON_BE(unknown);
string lastname(wxString::FromAscii("-noname-"));
size_t namecount = 0;
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Read the directory
mc.seek(dir_offset, SEEK_SET);
theSplashWindow->setProgressMessage("Reading dat archive data");
for (uint32_t d = 0; d < num_lumps; d++)
{
// Update splash window progress
theSplashWindow->setProgress(((float)d / (float)num_lumps));
// Read lump info
uint32_t offset = 0;
uint32_t size = 0;
uint16_t nameofs = 0;
uint16_t flags = 0;
mc.read(&offset, 4); // Offset
mc.read(&size, 4); // Size
mc.read(&nameofs, 2); // Name offset
mc.read(&flags, 2); // Flags (only one: RLE encoded)
// Byteswap values for big endian if needed
offset = wxINT32_SWAP_ON_BE(offset);
size = wxINT32_SWAP_ON_BE(size);
nameofs = wxINT16_SWAP_ON_BE(nameofs);
flags = wxINT16_SWAP_ON_BE(flags);
// If the lump data goes past the directory,
// the data file is invalid
if (offset + size > mc.getSize())
{
wxLogMessage("DatArchive::open: Dat archive is invalid or corrupt at entry %i", d);
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
string myname;
if (nameofs != 0)
{
size_t len = 1;
size_t start = nameofs+dir_offset;
for (size_t i = start; mcdata[i] != 0; ++i) { ++len; }
lastname = myname = wxString::FromAscii(mcdata+start, len);
namecount = 0;
}
else
{
myname = S_FMT("%s+%d", lastname, ++namecount);
}
// Create & setup lump
ArchiveEntry* nlump = new ArchiveEntry(myname, size);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)offset;
nlump->setState(0);
if (flags & 1) nlump->setEncryption(ENC_SCRLE0);
// Check for markers
if (!nlump->getName().Cmp("startflats"))
flats[0] = d;
if (!nlump->getName().Cmp("endflats"))
flats[1] = d;
if (!nlump->getName().Cmp("startsprites"))
sprites[0] = d;
if (!nlump->getName().Cmp("endmonsters"))
sprites[1] = d;
if (!nlump->getName().Cmp("startwalls"))
walls[0] = d;
if (!nlump->getName().Cmp("endwalls"))
walls[1] = d;
// Add to entry list
//.........这里部分代码省略.........
示例4: open
/* RffArchive::open
* Reads grp format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool RffArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Read grp header
uint8_t magic[4];
uint32_t version, dir_offset, num_lumps;
mc.seek(0, SEEK_SET);
mc.read(magic, 4); // Should be "RFF\x18"
mc.read(&version, 4); // 0x01 0x03 \x00 \x00
mc.read(&dir_offset, 4); // Offset to directory
mc.read(&num_lumps, 4); // No. of lumps in rff
// Byteswap values for big endian if needed
dir_offset = wxINT32_SWAP_ON_BE(dir_offset);
num_lumps = wxINT32_SWAP_ON_BE(num_lumps);
version = wxINT32_SWAP_ON_BE(version);
// Check the header
if (magic[0] != 'R' || magic[1] != 'F' || magic[2] != 'F' || magic[3] != 0x1A || version != 0x301)
{
wxLogMessage("RffArchive::openFile: File %s has invalid header", filename);
Global::error = "Invalid rff header";
return false;
}
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Read the directory
RFFLump* lumps = new RFFLump[num_lumps];
mc.seek(dir_offset, SEEK_SET);
theSplashWindow->setProgressMessage("Reading rff archive data");
mc.read (lumps, num_lumps * sizeof(RFFLump));
BloodCrypt (lumps, dir_offset, num_lumps * sizeof(RFFLump));
for (uint32_t d = 0; d < num_lumps; d++)
{
// Update splash window progress
theSplashWindow->setProgress(((float)d / (float)num_lumps));
// Read lump info
char name[13] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
uint32_t offset = wxINT32_SWAP_ON_BE(lumps[d].FilePos);
uint32_t size = wxINT32_SWAP_ON_BE(lumps[d].Size);
// Reconstruct name
int i, j = 0;
for (i = 0; i < 8; ++i)
{
if (lumps[d].Name[i] == 0) break;
name[i] = lumps[d].Name[i];
}
for (name[i++] = '.'; j < 3; ++j)
name[i+j] = lumps[d].Extension[j];
// If the lump data goes past the end of the file,
// the rfffile is invalid
if (offset + size > mc.getSize())
{
wxLogMessage("RffArchive::open: rff archive is invalid or corrupt");
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
// Create & setup lump
ArchiveEntry* nlump = new ArchiveEntry(wxString::FromAscii(name), size);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)offset;
nlump->setState(0);
// Is the entry encrypted?
if (lumps[d].Flags & 0x10)
nlump->setEncryption(ENC_BLOOD);
// Add to entry list
getRoot()->addEntry(nlump);
}
delete[] lumps;
// Detect all entry types
MemChunk edata;
theSplashWindow->setProgressMessage("Detecting entry types");
for (size_t a = 0; a < numEntries(); a++)
{
// Update splash window progress
theSplashWindow->setProgress((((float)a / (float)num_lumps)));
// Get entry
ArchiveEntry* entry = getEntry(a);
// Read entry data if it isn't zero-sized
if (entry->getSize() > 0)
//.........这里部分代码省略.........
示例5: open
/* GobArchive::open
* Reads gob format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool GobArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Check size
if (mc.getSize() < 12)
return false;
// Check magic header
if (mc[0] != 'G' || mc[1] != 'O' || mc[2] != 'B' || mc[3] != 0xA)
return false;
// Get directory offset
uint32_t dir_offset = 0;
mc.seek(4, SEEK_SET);
mc.read(&dir_offset, 4);
dir_offset = wxINT32_SWAP_ON_BE(dir_offset);
// Check size
if ((unsigned)mc.getSize() < (dir_offset + 4))
return false;
// Get number of lumps
uint32_t num_lumps = 0;
mc.seek(dir_offset, SEEK_SET);
mc.read(&num_lumps, 4);
num_lumps = wxINT32_SWAP_ON_BE(num_lumps);
// Compute directory size
uint32_t dir_size = (num_lumps * 21) + 4;
if ((unsigned)mc.getSize() < (dir_offset + dir_size))
return false;
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Read the directory
theSplashWindow->setProgressMessage("Reading gob archive data");
for (uint32_t d = 0; d < num_lumps; d++)
{
// Update splash window progress
theSplashWindow->setProgress(((float)d / (float)num_lumps));
// Read lump info
uint32_t offset = 0;
uint32_t size = 0;
char name[13] = "";
mc.read(&offset, 4); // Offset
mc.read(&size, 4); // Size
mc.read(name, 13); // Name
name[12] = '\0';
// Byteswap values for big endian if needed
size = wxINT32_SWAP_ON_BE(size);
// If the lump data goes past the end of the file,
// the gobfile is invalid
if (offset + size > mc.getSize())
{
wxLogMessage("GobArchive::open: gob archive is invalid or corrupt");
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
// Create & setup lump
ArchiveEntry* nlump = new ArchiveEntry(wxString::FromAscii(name), size);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)offset;
nlump->setState(0);
// Add to entry list
getRoot()->addEntry(nlump);
}
// Detect all entry types
MemChunk edata;
theSplashWindow->setProgressMessage("Detecting entry types");
for (size_t a = 0; a < numEntries(); a++)
{
// Update splash window progress
theSplashWindow->setProgress((((float)a / (float)num_lumps)));
// Get entry
ArchiveEntry* entry = getEntry(a);
// Read entry data if it isn't zero-sized
if (entry->getSize() > 0)
{
// Read the entry data
mc.exportMemChunk(edata, getEntryOffset(entry), entry->getSize());
entry->importMemChunk(edata);
}
//.........这里部分代码省略.........
示例6: ArchiveEntry
/* Wad2Archive::open
* Reads wad format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool Wad2Archive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Read wad header
uint32_t num_lumps = 0;
uint32_t dir_offset = 0;
char wad_type[4] = "";
mc.seek(0, SEEK_SET);
mc.read(&wad_type, 4); // Wad type
mc.read(&num_lumps, 4); // No. of lumps in wad
mc.read(&dir_offset, 4); // Offset to directory
// Byteswap values for big endian if needed
num_lumps = wxINT32_SWAP_ON_BE(num_lumps);
dir_offset = wxINT32_SWAP_ON_BE(dir_offset);
// Check the header
if (wad_type[0] != 'W' || wad_type[1] != 'A' || wad_type[2] != 'D' ||
(wad_type[3] != '2' && wad_type[3] != '3'))
{
wxLogMessage("Wad2Archive::open: Invalid header");
Global::error = "Invalid wad2 header";
return false;
}
if (wad_type[3] == '3')
wad3 = true;
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Read the directory
mc.seek(dir_offset, SEEK_SET);
theSplashWindow->setProgressMessage("Reading wad archive data");
for (uint32_t d = 0; d < num_lumps; d++)
{
// Update splash window progress
theSplashWindow->setProgress(((float)d / (float)num_lumps));
// Read lump info
wad2entry_t info;
mc.read(&info, 32);
// Byteswap values for big endian if needed
info.offset = wxINT32_SWAP_ON_BE(info.offset);
info.size = wxINT32_SWAP_ON_BE(info.size);
info.dsize = wxINT32_SWAP_ON_BE(info.dsize);
// If the lump data goes past the end of the file,
// the wadfile is invalid
if ((unsigned)(info.offset + info.dsize) > mc.getSize())
{
wxLogMessage("Wad2Archive::open: Wad2 archive is invalid or corrupt");
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
// Create & setup lump
ArchiveEntry* nlump = new ArchiveEntry(wxString::FromAscii(info.name, 16), info.dsize);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)info.offset;
nlump->exProp("W2Type") = info.type;
nlump->exProp("W2Size") = (int)info.size;
nlump->exProp("W2Comp") = !!(info.cmprs);
nlump->setState(0);
// Add to entry list
getRoot()->addEntry(nlump);
}
// Detect all entry types
MemChunk edata;
theSplashWindow->setProgressMessage("Detecting entry types");
for (size_t a = 0; a < numEntries(); a++)
{
// Update splash window progress
theSplashWindow->setProgress((((float)a / (float)num_lumps)));
// Get entry
ArchiveEntry* entry = getEntry(a);
// Read entry data if it isn't zero-sized
if (entry->getSize() > 0)
{
// Read the entry data
mc.exportMemChunk(edata, (int)entry->exProp("Offset"), entry->getSize());
entry->importMemChunk(edata);
}
// Detect entry type
EntryType::detectEntryType(entry);
// Unload entry data if needed
//.........这里部分代码省略.........
示例7: open
// -----------------------------------------------------------------------------
// Reads grp format data from a MemChunk
// Returns true if successful, false otherwise
// -----------------------------------------------------------------------------
bool GrpArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Read grp header
uint32_t num_lumps = 0;
char ken_magic[13] = "";
mc.seek(0, SEEK_SET);
mc.read(ken_magic, 12); // "KenSilverman"
mc.read(&num_lumps, 4); // No. of lumps in grp
// Byteswap values for big endian if needed
num_lumps = wxINT32_SWAP_ON_BE(num_lumps);
// Null-terminate the magic header
ken_magic[12] = 0;
// Check the header
if (!(S_CMP(wxString::FromAscii(ken_magic), "KenSilverman")))
{
Log::error(S_FMT("GrpArchive::openFile: File %s has invalid header", filename_));
Global::error = "Invalid grp header";
return false;
}
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// The header takes as much space as a directory entry
uint32_t entryoffset = 16 * (1 + num_lumps);
// Read the directory
UI::setSplashProgressMessage("Reading grp archive data");
for (uint32_t d = 0; d < num_lumps; d++)
{
// Update splash window progress
UI::setSplashProgress(((float)d / (float)num_lumps));
// Read lump info
char name[13] = "";
uint32_t offset = entryoffset;
uint32_t size = 0;
mc.read(name, 12); // Name
mc.read(&size, 4); // Size
name[12] = '\0';
// Byteswap values for big endian if needed
size = wxINT32_SWAP_ON_BE(size);
// Increase offset of next entry by this entry's size
entryoffset += size;
// If the lump data goes past the end of the file,
// the grpfile is invalid
if (offset + size > mc.size())
{
Log::error("GrpArchive::open: grp archive is invalid or corrupt");
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
// Create & setup lump
auto nlump = std::make_shared<ArchiveEntry>(wxString::FromAscii(name), size);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)offset;
nlump->setState(ArchiveEntry::State::Unmodified);
// Add to entry list
rootDir()->addEntry(nlump);
}
// Detect all entry types
MemChunk edata;
UI::setSplashProgressMessage("Detecting entry types");
for (size_t a = 0; a < numEntries(); a++)
{
// Update splash window progress
UI::setSplashProgress((((float)a / (float)num_lumps)));
// Get entry
auto entry = entryAt(a);
// Read entry data if it isn't zero-sized
if (entry->size() > 0)
{
// Read the entry data
mc.exportMemChunk(edata, getEntryOffset(entry), entry->size());
entry->importMemChunk(edata);
}
// Detect entry type
EntryType::detectEntryType(entry);
//.........这里部分代码省略.........
示例8: open
/* HogArchive::open
* Reads hog format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool HogArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Check size
size_t archive_size = mc.getSize();
if (archive_size < 3)
return false;
// Check magic header (DHF for "Descent Hog File")
if (mc[0] != 'D' || mc[1] != 'H' || mc[2] != 'F')
return false;
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Iterate through files to see if the size seems okay
theSplashWindow->setProgressMessage("Reading hog archive data");
size_t iter_offset = 3;
uint32_t num_lumps = 0;
while (iter_offset < archive_size)
{
// Update splash window progress
theSplashWindow->setProgress(((float)iter_offset / (float)archive_size));
// If the lump data goes past the end of the file,
// the hogfile is invalid
if (iter_offset + 17 > archive_size)
{
wxLogMessage("HogArchive::open: hog archive is invalid or corrupt");
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
// Setup variables
num_lumps++;
size_t offset = iter_offset + 17;
size_t size = READ_L32(mc, iter_offset + 13);
char name[14] = "";
mc.seek(iter_offset, SEEK_SET);
mc.read(name, 13);
name[13] = 0;
// Create & setup lump
ArchiveEntry* nlump = new ArchiveEntry(wxString::FromAscii(name), size);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)offset;
nlump->setState(0);
// Add to entry list
getRoot()->addEntry(nlump);
// Update entry size to compute next offset
iter_offset = offset + size;
}
// Detect all entry types
MemChunk edata;
theSplashWindow->setProgressMessage("Detecting entry types");
for (size_t a = 0; a < numEntries(); a++)
{
// Update splash window progress
theSplashWindow->setProgress((((float)a / (float)num_lumps)));
// Get entry
ArchiveEntry* entry = getEntry(a);
// Read entry data if it isn't zero-sized
if (entry->getSize() > 0)
{
// Read the entry data
mc.exportMemChunk(edata, getEntryOffset(entry), entry->getSize());
entry->importMemChunk(edata);
}
// Detect entry type
EntryType::detectEntryType(entry);
// Unload entry data if needed
if (!archive_load_data)
entry->unloadData();
// Set entry to unchanged
entry->setState(0);
}
// Setup variables
setMuted(false);
setModified(false);
announce("opened");
theSplashWindow->setProgressMessage("");
//.........这里部分代码省略.........
示例9: open
/* LfdArchive::open
* Reads lfd format data from a MemChunk
* Returns true if successful, false otherwise
*******************************************************************/
bool LfdArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Check size
if (mc.getSize() < 16)
return false;
// Check magic header
if (mc[0] != 'R' || mc[1] != 'M' || mc[2] != 'A' || mc[3] != 'P')
return false;
// Get directory length
uint32_t dir_len = 0;
mc.seek(12, SEEK_SET);
mc.read(&dir_len, 4);
dir_len = wxINT32_SWAP_ON_BE(dir_len);
// Check size
if ((unsigned)mc.getSize() < (dir_len) || dir_len % 16)
return false;
// Guess number of lumps
uint32_t num_lumps = dir_len / 16;
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Read each entry
theSplashWindow->setProgressMessage("Reading lfd archive data");
size_t offset = dir_len + 16;
size_t size = mc.getSize();
for (uint32_t d = 0; offset < size; d++)
{
// Update splash window progress
theSplashWindow->setProgress(((float)d / (float)num_lumps));
// Read lump info
uint32_t length = 0;
char type[5] = "";
char name[9] = "";
mc.read(type, 4); // Type
mc.read(name, 8); // Name
mc.read(&length, 4); // Size
name[8] = '\0'; type[4] = 0;
// Move past the header
offset += 16;
// Byteswap values for big endian if needed
length = wxINT32_SWAP_ON_BE(length);
// If the lump data goes past the end of the file,
// the gobfile is invalid
if (offset + length > size)
{
wxLogMessage("LfdArchive::open: lfd archive is invalid or corrupt");
Global::error = "Archive is invalid and/or corrupt";
setMuted(false);
return false;
}
// Create & setup lump
wxFileName fn(name);
fn.SetExt(type);
ArchiveEntry* nlump = new ArchiveEntry(fn.GetFullName(), length);
nlump->setLoaded(false);
nlump->exProp("Offset") = (int)offset;
nlump->setState(0);
// Add to entry list
getRoot()->addEntry(nlump);
// Move to next entry
offset += length;
mc.seek(offset, SEEK_SET);
}
if (num_lumps != numEntries())
wxLogMessage("Warning: computed %i lumps, but actually %i entries", num_lumps, numEntries());
// Detect all entry types
MemChunk edata;
theSplashWindow->setProgressMessage("Detecting entry types");
for (size_t a = 0; a < numEntries(); a++)
{
// Update splash window progress
theSplashWindow->setProgress((((float)a / (float)num_lumps)));
// Get entry
ArchiveEntry* entry = getEntry(a);
// Read entry data if it isn't zero-sized
//.........这里部分代码省略.........
示例10: open
// -----------------------------------------------------------------------------
// Reads pod format data from a MemChunk
// Returns true if successful, false otherwise
// -----------------------------------------------------------------------------
bool PodArchive::open(MemChunk& mc)
{
// Check data was given
if (!mc.hasData())
return false;
// Read no. of files
mc.seek(0, 0);
uint32_t num_files;
mc.read(&num_files, 4);
// Read id
mc.read(id_, 80);
// Read directory
vector<FileEntry> files(num_files);
mc.read(files.data(), num_files * sizeof(FileEntry));
// Stop announcements (don't want to be announcing modification due to entries being added etc)
setMuted(true);
// Create entries
UI::setSplashProgressMessage("Reading pod archive data");
for (unsigned a = 0; a < num_files; a++)
{
// Get the entry name as a wxFileName (so we can break it up)
wxFileName fn(files[a].name);
// Create entry
auto new_entry = std::make_shared<ArchiveEntry>(fn.GetFullName(), files[a].size);
new_entry->exProp("Offset") = files[a].offset;
new_entry->setLoaded(false);
// Add entry and directory to directory tree
string path = fn.GetPath(false);
auto ndir = createDir(path);
ndir->addEntry(new_entry);
new_entry->setState(ArchiveEntry::State::Unmodified);
LOG_MESSAGE(5, "File size: %d, offset: %d, name: %s", files[a].size, files[a].offset, files[a].name);
}
// Detect entry types
vector<ArchiveEntry*> all_entries;
putEntryTreeAsList(all_entries);
UI::setSplashProgressMessage("Detecting entry types");
for (unsigned a = 0; a < all_entries.size(); a++)
{
// Skip dir/marker
if (all_entries[a]->size() == 0 || all_entries[a]->type() == EntryType::folderType())
{
all_entries[a]->setState(ArchiveEntry::State::Unmodified);
continue;
}
// Update splash window progress
UI::setSplashProgress((float)a / (float)all_entries.size());
// Read data
MemChunk edata;
mc.exportMemChunk(edata, all_entries[a]->exProp("Offset").intValue(), all_entries[a]->size());
all_entries[a]->importMemChunk(edata);
// Detect entry type
EntryType::detectEntryType(all_entries[a]);
// Unload entry data if needed
if (!archive_load_data)
all_entries[a]->unloadData();
// Set entry to unchanged
all_entries[a]->setState(ArchiveEntry::State::Unmodified);
LOG_MESSAGE(5, "entry %s size %d", CHR(all_entries[a]->name()), all_entries[a]->size());
}
// Setup variables
setMuted(false);
setModified(false);
announce("opened");
UI::setSplashProgressMessage("");
return true;
}