Make fs.readdir support asar package.
This commit is contained in:
parent
9f9d209e3d
commit
0cab034dab
4 changed files with 80 additions and 12 deletions
|
@ -162,4 +162,25 @@ bool Archive::Stat(const base::FilePath& path, Stats* stats) {
|
|||
return FillFileInfoWithNode(stats, header_size_, node);
|
||||
}
|
||||
|
||||
bool Archive::Readdir(const base::FilePath& path,
|
||||
std::vector<base::FilePath>* list) {
|
||||
if (!header_)
|
||||
return false;
|
||||
|
||||
const base::DictionaryValue* node;
|
||||
if (!GetNodeFromPath(path.AsUTF8Unsafe(), header_.get(), &node))
|
||||
return false;
|
||||
|
||||
const base::DictionaryValue* files;
|
||||
if (!node->GetDictionaryWithoutPathExpansion("files", &files))
|
||||
return false;
|
||||
|
||||
base::DictionaryValue::Iterator iter(*files);
|
||||
while (!iter.IsAtEnd()) {
|
||||
list->push_back(base::FilePath::FromUTF8Unsafe(iter.key()));
|
||||
iter.Advance();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace asar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue