|
@@ -7,9 +7,11 @@
|
|
|
#include <vector>
|
|
|
|
|
|
#include "native_mate/arguments.h"
|
|
|
+#include "native_mate/dictionary.h"
|
|
|
#include "native_mate/object_template_builder_deprecated.h"
|
|
|
#include "native_mate/wrappable.h"
|
|
|
#include "shell/common/asar/archive.h"
|
|
|
+#include "shell/common/asar/asar_util.h"
|
|
|
#include "shell/common/gin_converters/callback_converter.h"
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
|
#include "shell/common/native_mate_converters/file_path_converter.h"
|
|
@@ -127,12 +129,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) {
|
|
|
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
|
|
dict.SetMethod("createArchive", &Archive::Create);
|
|
|
+ dict.SetMethod("splitPath", &SplitPath);
|
|
|
dict.SetMethod("initAsarSupport", &InitAsarSupport);
|
|
|
}
|
|
|
|