Add a way to copy a file in archive into filesystem.
This commit is contained in:
parent
e5e1e207b6
commit
c95a93ef1c
6 changed files with 138 additions and 1 deletions
|
@ -7,10 +7,12 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/common/asar/scoped_temporary_file.h"
|
||||
#include "base/files/file.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/pickle.h"
|
||||
#include "base/json/json_string_value_serializer.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
|
||||
namespace asar {
|
||||
|
@ -181,4 +183,23 @@ bool Archive::Readdir(const base::FilePath& path,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
||||
if (ContainsKey(external_files_, path)) {
|
||||
*out = external_files_[path]->path();
|
||||
return true;
|
||||
}
|
||||
|
||||
FileInfo info;
|
||||
if (!GetFileInfo(path, &info))
|
||||
return false;
|
||||
|
||||
scoped_refptr<ScopedTemporaryFile> temp_file(new ScopedTemporaryFile);
|
||||
if (!temp_file->InitFromFile(path_, info.offset, info.size))
|
||||
return false;
|
||||
|
||||
external_files_[path] = temp_file;
|
||||
*out = temp_file->path();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace asar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue