本文整理汇总了C++中DirectoryEntry::getDirectories方法的典型用法代码示例。如果您正苦于以下问题:C++ DirectoryEntry::getDirectories方法的具体用法?C++ DirectoryEntry::getDirectories怎么用?C++ DirectoryEntry::getDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryEntry
的用法示例。
在下文中一共展示了DirectoryEntry::getDirectories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDirectoryEntryCount
int LafsFlat::getDirectoryEntryCount(const DirectoryEntry& dir)
{
int iEntryCount = 2; //2 for root entry 1 (root directory) + 1 (jump directory)
std::vector<DirectoryEntry> it = dir.getDirectories();
for(std::vector<DirectoryEntry>::const_iterator it = dir.getDirectories().begin();
it != dir.getDirectories().end();
it++)
iEntryCount += getDirectoryEntryCount(*it);
return iEntryCount;
}
示例2: getFileIndexSize
WORD RsfsFormatter::getFileIndexSize(const DirectoryEntry& rootDir)
{
const std::vector<DirectoryEntry>& dirs = rootDir.getDirectories();
WORD wDataRegionOffset = rootDir.getFiles().size() * RSFS_FILEENTRY_SIZE + dirs.size() * RSFS_DIRECTORYENTRY_SIZE;
for(std::vector<DirectoryEntry>::const_iterator it = dirs.begin(); it != dirs.end(); it++)
wDataRegionOffset += getFileIndexSize(*it);
return wDataRegionOffset;
}
示例3: create
void RsfsFormatter::create(std::ostream& out, const DirectoryEntry& rootDir)
{
std::stringstream ssFileIndexBuffer;
std::stringstream ssFileRawBuffer;
WORD wDataRegionOffset = getFileIndexSize(rootDir) + RSFS_HEADER_SIZE;
writeDirectory(rootDir, wDataRegionOffset, ssFileIndexBuffer, ssFileRawBuffer);
//Write out header
out.put(1);
out.put(0);
WORD numRootEntries = rootDir.getDirectories().size() + rootDir.getFiles().size();
out.write(reinterpret_cast<char*>(&numRootEntries), sizeof(WORD));
//write file directories
for(unsigned char b = ssFileIndexBuffer.get(); !ssFileIndexBuffer.eof(); b = ssFileIndexBuffer.get())
out.put(b);
for(unsigned char b = ssFileRawBuffer.get(); !ssFileRawBuffer.eof(); b = ssFileRawBuffer.get())
out.put(b);
}
示例4: writeDirectory
void RsfsFormatter::writeDirectory(const DirectoryEntry& dir, const WORD wDataRegionOffset, std::ostream& fileIndexBuffer, std::ostream& fileRawDataBuffer)
{
char fileReadBuffer[100];
const std::vector<DirectoryEntry>& dirs = dir.getDirectories();
const std::vector<FileEntry>& files = dir.getFiles();
WORD wBuffer = 0;
if(dir.getName().length() > 0)
{
wBuffer = RSFS_ENTRYTYPE_DIRECTORY;
fileIndexBuffer.write(reinterpret_cast<char*>(&wBuffer), sizeof(WORD));
fileIndexBuffer.write(dir.getName().c_str(), dir.getName().length());
for(unsigned int i = RSFS_NAME_SIZE - dir.getName().length(); i > 0; i--)
fileIndexBuffer.put(0);
if(dir.getDirectories().size() > 0xFFFF)
throw FormattingException("The number of sub-directories exceeds the max permittable number of sub-directories.");
wBuffer = static_cast<WORD>(dir.getDirectories().size() + dir.getFiles().size());
fileIndexBuffer.write(reinterpret_cast<char*>(&wBuffer), sizeof(WORD));
fileIndexBuffer.put(0);
fileIndexBuffer.put(0);
}
for(std::vector<FileEntry>::const_iterator it = files.begin(); it != files.end(); it++)
{
if(it->getName().length() >= RSFS_NAME_SIZE)
{
throw new FormattingException(std::string("Skipped due to file name exceeding max length: ") + it->getName());
continue;
}
wBuffer = RSFS_ENTRYTYPE_FILE;
fileIndexBuffer.write(reinterpret_cast<char*>(&wBuffer), sizeof(WORD));
fileIndexBuffer.write(it->getName().c_str(), it->getName().length());
//Padd the file name with nulls.
for(unsigned int i = RSFS_NAME_SIZE - it->getName().length(); i > 0; i--)
fileIndexBuffer.put(0);
if(it->getSize() > 0xFFFF)
throw FormattingException("Size of file exceeded permitable size.");
wBuffer = static_cast<WORD>(it->getSize());
fileIndexBuffer.write(reinterpret_cast<char*>(&wBuffer), sizeof(WORD));
//Make sure data is aligned in words
std::streamoff offset = 0;
for(offset = wDataRegionOffset + fileRawDataBuffer.tellp(); offset % 2; offset++)
fileRawDataBuffer.put(0);
if(offset + it->getSize() > 0xFFFF)
throw FormattingException("Size of medium exceeded permitable size.");
WORD wFileDataOffset = static_cast<WORD>(offset) / 2; //Offset in terms of words.
fileIndexBuffer.write(reinterpret_cast<char*>(&wFileDataOffset), sizeof(WORD));
//Write our file's data to the fileRawBuffer.
std::ifstream inFile(it->getSourceFile(), std::ifstream::binary | std::ifstream::in);
if(!inFile.good())
throw FormattingException(std::string("Error reading from source file") + it->getName());
while(!inFile.eof())
{
inFile.read(fileReadBuffer, sizeof(fileReadBuffer));
fileRawDataBuffer.write(fileReadBuffer, inFile.gcount());
}
}
for(std::vector<DirectoryEntry>::const_iterator it = dirs.begin(); it != dirs.end(); it++)
writeDirectory(*it, wDataRegionOffset, fileIndexBuffer, fileRawDataBuffer);
}