asar: Add support in fs.realpathSync

This commit is contained in:
Cheng Zhao 2014-09-30 14:53:41 +08:00
parent d77bf0440c
commit 885ac53a48
4 changed files with 48 additions and 4 deletions

View file

@ -206,6 +206,24 @@ bool Archive::Readdir(const base::FilePath& path,
return true;
}
bool Archive::Realpath(const base::FilePath& path, base::FilePath* realpath) {
if (!header_)
return false;
const base::DictionaryValue* node;
if (!GetNodeFromPath(path.AsUTF8Unsafe(), header_.get(), &node))
return false;
std::string link;
if (node->GetString("link", &link)) {
*realpath = base::FilePath::FromUTF8Unsafe(link);
return true;
}
*realpath = path;
return true;
}
bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
if (external_files_.contains(path)) {
*out = external_files_.get(path)->path();

View file

@ -51,6 +51,9 @@ class Archive {
// Fs.readdir(path).
bool Readdir(const base::FilePath& path, std::vector<base::FilePath>* files);
// Fs.realpath(path).
bool Realpath(const base::FilePath& path, base::FilePath* realpath);
// Copy the file into a temporary file, and return the new path.
bool CopyFileOut(const base::FilePath& path, base::FilePath* out);