本文整理汇总了C++中FileSystem::Entries方法的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem::Entries方法的具体用法?C++ FileSystem::Entries怎么用?C++ FileSystem::Entries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::Entries方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: List
void List(const char* file)
{
FileSystem fs;
if (fs.Open(file))
{
auto it = fs.Entries().begin();
for (; it != fs.Entries().end(); it++)
{
const FileEntry& entry = it->second;
FILEPACKER_LOGV("%s\n", entry.path.c_str());
}
}
else
{
FILEPACKER_LOGE("ERROR: Unable to open %s\n", file);
}
}
示例2: Extract
void Extract(ExtractParameters* extractparams)
{
FileSystem fs;
if (fs.Open(extractparams->file))
{
if (!CreateDir(extractparams->out_path))
{
FILEPACKER_LOGE("ERROR: Unable to create %s\n", extractparams->out_path);
return;
}
std::string out_path(extractparams->out_path);
std::set<std::string> dirs;
auto it = fs.Entries().begin();
for (; it != fs.Entries().end(); it++)
{
const FileEntry& entry = it->second;
size_t found = entry.path.find_last_of("/\\");
if (found != std::string::npos)
{
std::string path = entry.path.substr(0, found);
found = 0;
while (1)
{
found = path.find_first_of("/\\", found);
std::string curr = path.substr(0, found);
if (dirs.find(curr) == dirs.end())
{
std::string full_dir = out_path + "/" + curr;
if (!CreateDir(full_dir.c_str()))
{
FILEPACKER_LOGE("ERROR: Unable to create %s\n", full_dir.c_str());
}
else
{
FILEPACKER_LOGV(" + Created dir %s\n", curr.c_str());
}
dirs.insert(curr);
}
if (found == std::string::npos)
break;
found++;
}
}
unsigned char* buffer = new unsigned char[entry.header.uncompr_size];
fs.Read(entry, buffer);
std::string full_dir = out_path + "/" + entry.path;
FILE* f = fopen(full_dir.c_str(), "wb+");
if (f != NULL)
{
FILEPACKER_LOGV(" + Writing %s\n", entry.path.c_str());
fwrite(buffer, 1, entry.header.uncompr_size, f);
fclose(f);
}
else
{
FILEPACKER_LOGE("ERROR: Unable to write %s\n", entry.path.c_str());
}
}
}
else
{
FILEPACKER_LOGE("ERROR: Unable to open %s\n", extractparams->file);
}
}