-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvfs_module.cjs
158 lines (147 loc) · 4.59 KB
/
vfs_module.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
"use strict";
var sack, errN = [];
try {
//sack = require('sack' );
//console.log( "Got sack loaded?" );
} catch( err ) {
errN.push(err);
}
let basePath = ( process.platform === "win32" )?process.env.PATH:null;
let isGUI = false;
function includeNative( gui ) {
isGUI = gui;
const name = gui?"sack_gui.node":"sack_vfs.node";
if( !sack )
if( process.platform === 'browser' ) { // electron
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\Release\\bin"
+";"+__dirname+"\\build\\Release\\share\\SACK\\plugins"
sack = require( "./build/Release/" + name );
} catch( err ){
errN.push(err);
}
if( !sack )
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\Debug\\bin"
+";"+__dirname+"\\build\\Debug\\share\\SACK\\plugins"
sack = require( "./build/Debug/" + name );
} catch( err ){
errN.push(err);
}
if( !sack )
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\RelWithDebInfo\\bin"
+";"+__dirname+"\\build\\RelWithDebInfo\\share\\SACK\\plugins"
sack = require( "./build/RelWithDebInfo/" + name );
} catch( err ){
errN.push(err);
}
} else if( process.platform === 'win32' ) {
try {
if( process.config.target_defaults.default_configuration === 'Debug'
|| ( Number(process.version.split('.')[0].split('v')[1]) >= 16 )
|| ( Number(process.version.split('.')[0].split('v')[1]) < 12 ) ) {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\Debug\\bin"
+";"+__dirname+"\\build\\Debug\\share\\SACK\\plugins"
sack = require( "./build/Debug/" + name );
}
} catch( err ){
errN.push(err);
}
if( process.config.target_defaults.default_configuration === 'Release' ) {
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\RelWithDebInfo\\bin"
+";"+__dirname+"\\build\\RelWithDebInfo\\share\\SACK\\plugins"
sack = require( "./build/RelWithDebInfo/" + name );
} catch( err ){
errN.push(err);
}
if( !sack )
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\Release\\bin"
+";"+__dirname+"\\build\\Release\\share\\SACK\\plugins"
sack = require( "./build/Release/" + name );
} catch( err ){
errN.push(err);
}
}
} else {
if( !sack )
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\RelWithDebInfo\\bin"
+";"+__dirname+"\\build\\RelWithDebInfo\\share\\SACK\\plugins"
sack = require( "./build/RelWithDebInfo/" + name );
} catch( err ){
errN.push(err);
}
if( !sack )
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\Debug\\bin"
+";"+__dirname+"\\build\\Debug\\share\\SACK\\plugins"
sack = require( "./build/Debug/" + name );
} catch( err ){
errN.push(err);
}
if( !sack )
try {
if( gui && basePath )
process.env.PATH = basePath
+";"+__dirname+"\\build\\Release\\bin"
+";"+__dirname+"\\build\\Release\\share\\SACK\\plugins"
sack = require( "./build/Release/" + name );
} catch( err ){
errN.push(err);
}
}
if( !sack && !gui ) includeNative( true );
}
includeNative( false );
if( !sack ) {
if( "undefined" !== typeof log ) {
log( errN.join(',') );
}
const util = require('util');
throw new Error( util.format( "Failed to match configuration:", process && process.config && process.config.target_defaults && process.config.target_defaults.default_configuration, "\n", errN.join(',') ) );
}
module.exports=exports=sack;
require( "./sack-jsox.cjs" )(sack);
require( "./object-storage.cjs" )(sack);
require( "./object-storage-cb.cjs" )(sack);
//if( process.platform === "win32" )
// require( "./service-object.cjs" )(sack);
/*
process.on('exit', ()=>{
console.log( "exit in sack.vfs addon" );
} );
process.on('beforeExit', ()=>{
console.log( "beforeExit in sack.vfs addon" );
} );
*/
// this allowed ctrl-C to be a graceful exit...
// not sure why it wasn't without this though...
if(isGUI)
process.on('SIGINT', ()=>{
//console.log( "sigint (early?) in sack.vfs addon" );
sack.sigint();
//process.emit( "exit" );
//process.exit(0);
} )
// needed to dispatch promise resolutions that have been created in callbacks.
if (process._tickDomainCallback || process._tickCallback)
sack.Thread(process._tickDomainCallback || process._tickCallback);