本文整理汇总了C++中DirectoryEntry::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ DirectoryEntry::getName方法的具体用法?C++ DirectoryEntry::getName怎么用?C++ DirectoryEntry::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryEntry
的用法示例。
在下文中一共展示了DirectoryEntry::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}