Add a way to copy a file in archive into filesystem.

This commit is contained in:
Cheng Zhao 2014-09-25 16:56:50 +08:00
parent e5e1e207b6
commit c95a93ef1c
6 changed files with 138 additions and 1 deletions

View file

@ -67,13 +67,23 @@ class Archive : public mate::Wrappable {
return mate::ConvertToV8(isolate, files);
}
// Copy the file out into a temporary file and returns the new path.
v8::Handle<v8::Value> CopyFileOut(v8::Isolate* isolate,
const base::FilePath& path) {
base::FilePath new_path;
if (!archive_->CopyFileOut(path, &new_path))
return v8::False(isolate);
return mate::ConvertToV8(isolate, new_path);
}
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetValue("path", archive_->path())
.SetMethod("getFileInfo", &Archive::GetFileInfo)
.SetMethod("stat", &Archive::Stat)
.SetMethod("readdir", &Archive::Readdir);
.SetMethod("readdir", &Archive::Readdir)
.SetMethod("copyFileOut", &Archive::CopyFileOut);
}
private: