asar: Add support in fs.realpathSync
This commit is contained in:
parent
d77bf0440c
commit
885ac53a48
4 changed files with 48 additions and 4 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue