mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "shell/common/asar/archive.h"
|
||||
#include "shell/common/asar/asar_util.h"
|
||||
#include "shell/common/native_mate_converters/callback.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
@@ -127,12 +128,27 @@ void InitAsarSupport(v8::Isolate* isolate, v8::Local<v8::Value> require) {
|
||||
&asar_init_params, &asar_init_args, nullptr);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> SplitPath(v8::Isolate* isolate,
|
||||
const base::FilePath& path) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
base::FilePath asar_path, file_path;
|
||||
if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) {
|
||||
dict.Set("isAsar", true);
|
||||
dict.Set("asarPath", asar_path);
|
||||
dict.Set("filePath", file_path);
|
||||
} else {
|
||||
dict.Set("isAsar", false);
|
||||
}
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createArchive", &Archive::Create);
|
||||
dict.SetMethod("splitPath", &SplitPath);
|
||||
dict.SetMethod("initAsarSupport", &InitAsarSupport);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user