Skip to content

Commit 3269ce7

Browse files
committed
Runtime: jsoo_is_win32
1 parent 9aa8d2c commit 3269ce7

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

runtime/js/fs.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function MlFile() {}
5050

5151
//Provides: path_is_absolute
5252
//Requires: fs_node_supported
53+
//Requires: jsoo_is_win32
5354
function make_path_is_absolute() {
5455
function posix(path) {
5556
if (path.charAt(0) === "/") return ["", path.slice(1)];
@@ -72,13 +73,7 @@ function make_path_is_absolute() {
7273
}
7374
return;
7475
}
75-
if (
76-
fs_node_supported() &&
77-
globalThis.process &&
78-
globalThis.process.platform
79-
) {
80-
return globalThis.process.platform === "win32" ? win32 : posix;
81-
} else return posix;
76+
return jsoo_is_win32 ? win32 : posix;
8277
}
8378
var path_is_absolute = make_path_is_absolute();
8479

runtime/js/fs_node.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
// along with this program; if not, write to the Free Software
1818
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919

20+
//Provides: jsoo_is_win32
21+
var jsoo_is_win32 =
22+
globalThis.Deno?.build?.os === "windows" ||
23+
globalThis.process?.platform === "win32";
24+
2025
//Provides: fs_node_supported
2126
function fs_node_supported() {
2227
return globalThis.process?.versions?.node !== undefined;
@@ -30,6 +35,7 @@ function fs_node_supported() {
3035
//Provides: MlNodeDevice
3136
//Requires: MlNodeFd, caml_raise_sys_error, caml_string_of_jsstring
3237
//Requires: caml_raise_nodejs_error, fs_node_stats_from_js
38+
//Requires: jsoo_is_win32
3339
class MlNodeDevice {
3440
constructor(root) {
3541
this.fs = require("node:fs");
@@ -133,10 +139,7 @@ class MlNodeDevice {
133139
res |= consts.W_OK;
134140
break;
135141
case "x":
136-
res |=
137-
globalThis.process?.platform === "win32"
138-
? consts.R_OK
139-
: consts.X_OK;
142+
res |= jsoo_is_win32 ? consts.R_OK : consts.X_OK;
140143
break;
141144
case "f":
142145
res |= consts.F_OK;
@@ -210,7 +213,7 @@ class MlNodeDevice {
210213
}
211214

212215
rename(o, n, raise_unix) {
213-
if (globalThis.process?.platform === "win32") {
216+
if (jsoo_is_win32) {
214217
try {
215218
var target = this.nm(n);
216219
var source = this.nm(o);

runtime/js/sys.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ function caml_sys_const_backend_type() {
298298
}
299299

300300
//Provides: os_type
301-
var os_type = globalThis.process?.platform === "win32" ? "Win32" : "Unix";
301+
//Requires: jsoo_is_win32
302+
var os_type = jsoo_is_win32 ? "Win32" : "Unix";
302303

303304
//Provides: caml_sys_get_config const
304305
//Requires: caml_string_of_jsbytes, os_type

0 commit comments

Comments
 (0)