forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.zig
660 lines (583 loc) · 27.5 KB
/
bin.zig
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
const ExternalStringList = @import("./install.zig").ExternalStringList;
const Semver = @import("./semver.zig");
const ExternalString = Semver.ExternalString;
const String = Semver.String;
const std = @import("std");
const strings = @import("root").bun.strings;
const Environment = @import("../env.zig");
const Path = @import("../resolver/resolve_path.zig");
const C = @import("../c.zig");
const Fs = @import("../fs.zig");
const stringZ = @import("root").bun.stringZ;
const Resolution = @import("./resolution.zig").Resolution;
const bun = @import("root").bun;
/// Normalized `bin` field in [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin)
/// Can be a:
/// - file path (relative to the package root)
/// - directory (relative to the package root)
/// - map where keys are names of the binaries and values are file paths to the binaries
pub const Bin = extern struct {
tag: Tag = Tag.none,
value: Value = Value{ .none = {} },
pub fn verify(this: *const Bin, extern_strings: []const ExternalString) void {
if (comptime !Environment.allow_assert)
return;
switch (this.tag) {
.file => this.value.file.assertDefined(),
.named_file => {
this.value.named_file[0].assertDefined();
this.value.named_file[1].assertDefined();
},
.dir => {
this.value.dir.assertDefined();
},
.map => {
const list = this.value.map.get(extern_strings);
for (list) |*extern_string| {
extern_string.value.assertDefined();
}
},
else => {},
}
}
pub fn count(this: *const Bin, buf: []const u8, extern_strings: []const ExternalString, comptime StringBuilder: type, builder: StringBuilder) u32 {
switch (this.tag) {
.file => builder.count(this.value.file.slice(buf)),
.named_file => {
builder.count(this.value.named_file[0].slice(buf));
builder.count(this.value.named_file[1].slice(buf));
},
.dir => builder.count(this.value.dir.slice(buf)),
.map => {
const list = this.value.map.get(extern_strings);
for (list) |*extern_string| {
builder.count(extern_string.slice(buf));
}
return @as(u32, @truncate(list.len));
},
else => {},
}
return 0;
}
pub fn clone(this: *const Bin, buf: []const u8, prev_external_strings: []const ExternalString, all_extern_strings: []ExternalString, extern_strings_slice: []ExternalString, comptime StringBuilder: type, builder: StringBuilder) Bin {
return switch (this.tag) {
.none => Bin{ .tag = .none, .value = .{ .none = {} } },
.file => Bin{
.tag = .file,
.value = .{ .file = builder.append(String, this.value.file.slice(buf)) },
},
.named_file => Bin{
.tag = .named_file,
.value = .{
.named_file = [2]String{
builder.append(String, this.value.named_file[0].slice(buf)),
builder.append(String, this.value.named_file[1].slice(buf)),
},
},
},
.dir => Bin{
.tag = .dir,
.value = .{ .dir = builder.append(String, this.value.dir.slice(buf)) },
},
.map => {
for (this.value.map.get(prev_external_strings), 0..) |extern_string, i| {
extern_strings_slice[i] = builder.append(ExternalString, extern_string.slice(buf));
}
return .{
.tag = .map,
.value = .{ .map = ExternalStringList.init(all_extern_strings, extern_strings_slice) },
};
},
};
}
pub const Value = extern union {
/// no "bin", or empty "bin"
none: void,
/// "bin" is a string
/// ```
/// "bin": "./bin/foo",
/// ```
file: String,
// Single-entry map
///```
/// "bin": {
/// "babel": "./cli.js",
/// }
///```
named_file: [2]String,
/// "bin" is a directory
///```
/// "dirs": {
/// "bin": "./bin",
/// }
///```
dir: String,
// "bin" is a map
///```
/// "bin": {
/// "babel": "./cli.js",
/// "babel-cli": "./cli.js",
/// }
///```
map: ExternalStringList,
};
pub const Tag = enum(u8) {
/// no bin field
none = 0,
/// "bin" is a string
/// ```
/// "bin": "./bin/foo",
/// ```
file = 1,
// Single-entry map
///```
/// "bin": {
/// "babel": "./cli.js",
/// }
///```
named_file = 2,
/// "bin" is a directory
///```
/// "dirs": {
/// "bin": "./bin",
/// }
///```
dir = 3,
// "bin" is a map of more than one
///```
/// "bin": {
/// "babel": "./cli.js",
/// "babel-cli": "./cli.js",
/// "webpack-dev-server": "./cli.js",
/// }
///```
map = 4,
};
pub const NamesIterator = struct {
bin: Bin,
i: usize = 0,
done: bool = false,
dir_iterator: ?std.fs.IterableDir.Iterator = null,
package_name: String,
package_installed_node_modules: std.fs.Dir = std.fs.Dir{ .fd = std.math.maxInt(std.os.fd_t) },
buf: [bun.MAX_PATH_BYTES]u8 = undefined,
string_buffer: []const u8,
extern_string_buf: []const ExternalString,
fn nextInDir(this: *NamesIterator) !?[]const u8 {
if (this.done) return null;
if (this.dir_iterator == null) {
var target = this.bin.value.dir.slice(this.string_buffer);
if (strings.hasPrefix(target, "./")) {
target = target[2..];
}
var parts = [_][]const u8{ this.package_name.slice(this.string_buffer), target };
var dir = this.package_installed_node_modules;
var joined = Path.joinStringBuf(&this.buf, &parts, .auto);
this.buf[joined.len] = 0;
var joined_: [:0]u8 = this.buf[0..joined.len :0];
var child_dir = try bun.openDir(dir, joined_);
this.dir_iterator = child_dir.iterate();
}
var iter = &this.dir_iterator.?;
if (iter.next() catch null) |entry| {
this.i += 1;
return entry.name;
} else {
this.done = true;
this.dir_iterator.?.dir.close();
this.dir_iterator = null;
return null;
}
}
/// next filename, e.g. "babel" instead of "cli.js"
pub fn next(this: *NamesIterator) !?[]const u8 {
switch (this.bin.tag) {
.file => {
if (this.i > 0) return null;
this.i += 1;
this.done = true;
const base = std.fs.path.basename(this.package_name.slice(this.string_buffer));
if (strings.hasPrefix(base, "./"))
return strings.copy(&this.buf, base[2..]);
return strings.copy(&this.buf, base);
},
.named_file => {
if (this.i > 0) return null;
this.i += 1;
this.done = true;
const base = std.fs.path.basename(this.bin.value.named_file[0].slice(this.string_buffer));
if (strings.hasPrefix(base, "./"))
return strings.copy(&this.buf, base[2..]);
return strings.copy(&this.buf, base);
},
.dir => return try this.nextInDir(),
.map => {
if (this.i >= this.bin.value.map.len) return null;
const index = this.i;
this.i += 2;
this.done = this.i >= this.bin.value.map.len;
const current_string = this.bin.value.map.get(
this.extern_string_buf,
)[index];
const base = std.fs.path.basename(
current_string.slice(
this.string_buffer,
),
);
if (strings.hasPrefix(base, "./"))
return strings.copy(&this.buf, base[2..]);
return strings.copy(&this.buf, base);
},
else => return null,
}
}
};
pub const Linker = struct {
bin: Bin,
package_installed_node_modules: std.os.fd_t = std.math.maxInt(std.os.fd_t),
root_node_modules_folder: std.os.fd_t = std.math.maxInt(std.os.fd_t),
/// Used for generating relative paths
package_name: strings.StringOrTinyString,
global_bin_dir: std.fs.Dir,
global_bin_path: stringZ = "",
string_buf: []const u8,
extern_string_buf: []const ExternalString,
err: ?anyerror = null,
pub var umask: std.os.mode_t = 0;
pub const Error = error{
NotImplementedYet,
} || std.os.SymLinkError || std.os.OpenError || std.os.RealPathError;
fn unscopedPackageName(name: []const u8) []const u8 {
if (name[0] != '@') return name;
var name_ = name;
name_ = name[1..];
return name_[(strings.indexOfChar(name_, '/') orelse return name) + 1 ..];
}
fn setPermissions(folder: std.os.fd_t, target: [:0]const u8) void {
// we use fchmodat to avoid any issues with current working directory
_ = C.fchmodat(folder, target, umask | 0o777, 0);
}
fn setSimlinkAndPermissions(this: *Linker, target_path: [:0]const u8, dest_path: [:0]const u8) void {
std.os.symlinkatZ(target_path, this.root_node_modules_folder, dest_path) catch |err| {
// Silently ignore PathAlreadyExists
// Most likely, the symlink was already created by another package
if (err == error.PathAlreadyExists) {
setPermissions(this.root_node_modules_folder, dest_path);
var target_path_trim = target_path;
if (strings.hasPrefix(target_path_trim, "../")) {
target_path_trim = target_path_trim[3..];
}
setPermissions(this.package_installed_node_modules, target_path_trim);
return;
}
this.err = err;
};
setPermissions(this.root_node_modules_folder, dest_path);
}
const dot_bin = ".bin" ++ std.fs.path.sep_str;
// It is important that we use symlinkat(2) with relative paths instead of symlink()
// That way, if you move your node_modules folder around, the symlinks in .bin still work
// If we used absolute paths for the symlinks, you'd end up with broken symlinks
pub fn link(this: *Linker, link_global: bool) void {
var target_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var dest_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var from_remain: []u8 = &target_buf;
var remain: []u8 = &dest_buf;
if (!link_global) {
const root_dir = std.fs.Dir{ .fd = this.root_node_modules_folder };
const from = root_dir.realpath(dot_bin, &target_buf) catch |err| {
this.err = err;
return;
};
const to = bun.getFdPath(this.package_installed_node_modules, &dest_buf) catch |err| {
this.err = err;
return;
};
const rel = Path.relative(from, to);
bun.copy(u8, remain, rel);
remain = remain[rel.len..];
remain[0] = std.fs.path.sep;
remain = remain[1..];
from_remain[0..dot_bin.len].* = dot_bin.*;
from_remain = from_remain[dot_bin.len..];
} else {
if (this.global_bin_dir.fd >= std.math.maxInt(std.os.fd_t)) {
this.err = error.MissingGlobalBinDir;
return;
}
bun.copy(u8, &target_buf, this.global_bin_path);
from_remain = target_buf[this.global_bin_path.len..];
from_remain[0] = std.fs.path.sep;
from_remain = from_remain[1..];
const abs = bun.getFdPath(this.root_node_modules_folder, &dest_buf) catch |err| {
this.err = err;
return;
};
remain = remain[abs.len..];
remain[0] = std.fs.path.sep;
remain = remain[1..];
this.root_node_modules_folder = this.global_bin_dir.fd;
}
const name = this.package_name.slice();
bun.copy(u8, remain, name);
remain = remain[name.len..];
remain[0] = std.fs.path.sep;
remain = remain[1..];
if (comptime Environment.isWindows) {
@compileError("Bin.Linker.link() needs to be updated to generate .cmd files on Windows");
}
switch (this.bin.tag) {
.none => {
if (comptime Environment.isDebug) {
unreachable;
}
},
.file => {
var target = this.bin.value.file.slice(this.string_buf);
if (strings.hasPrefixComptime(target, "./")) {
target = target["./".len..];
}
bun.copy(u8, remain, target);
remain = remain[target.len..];
remain[0] = 0;
const target_len = @intFromPtr(remain.ptr) - @intFromPtr(&dest_buf);
remain = remain[1..];
var target_path: [:0]u8 = dest_buf[0..target_len :0];
// we need to use the unscoped package name here
// this is why @babel/parser would fail to link
const unscoped_name = unscopedPackageName(name);
bun.copy(u8, from_remain, unscoped_name);
from_remain = from_remain[unscoped_name.len..];
from_remain[0] = 0;
var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0];
this.setSimlinkAndPermissions(target_path, dest_path);
},
.named_file => {
var target = this.bin.value.named_file[1].slice(this.string_buf);
if (strings.hasPrefixComptime(target, "./")) {
target = target["./".len..];
}
bun.copy(u8, remain, target);
remain = remain[target.len..];
remain[0] = 0;
const target_len = @intFromPtr(remain.ptr) - @intFromPtr(&dest_buf);
remain = remain[1..];
var target_path: [:0]u8 = dest_buf[0..target_len :0];
var name_to_use = this.bin.value.named_file[0].slice(this.string_buf);
bun.copy(u8, from_remain, name_to_use);
from_remain = from_remain[name_to_use.len..];
from_remain[0] = 0;
var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0];
this.setSimlinkAndPermissions(target_path, dest_path);
},
.map => {
var extern_string_i: u32 = this.bin.value.map.off;
const end = this.bin.value.map.len + extern_string_i;
const _from_remain = from_remain;
const _remain = remain;
while (extern_string_i < end) : (extern_string_i += 2) {
from_remain = _from_remain;
remain = _remain;
const name_in_terminal = this.extern_string_buf[extern_string_i];
const name_in_filesystem = this.extern_string_buf[extern_string_i + 1];
var target = name_in_filesystem.slice(this.string_buf);
if (strings.hasPrefixComptime(target, "./")) {
target = target["./".len..];
}
bun.copy(u8, remain, target);
remain = remain[target.len..];
remain[0] = 0;
const target_len = @intFromPtr(remain.ptr) - @intFromPtr(&dest_buf);
remain = remain[1..];
var target_path: [:0]u8 = dest_buf[0..target_len :0];
var name_to_use = name_in_terminal.slice(this.string_buf);
bun.copy(u8, from_remain, name_to_use);
from_remain = from_remain[name_to_use.len..];
from_remain[0] = 0;
var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0];
this.setSimlinkAndPermissions(target_path, dest_path);
}
},
.dir => {
var target = this.bin.value.dir.slice(this.string_buf);
if (strings.hasPrefixComptime(target, "./")) {
target = target["./".len..];
}
var parts = [_][]const u8{ name, target };
bun.copy(u8, remain, target);
remain = remain[target.len..];
var dir = std.fs.Dir{ .fd = this.package_installed_node_modules };
var joined = Path.joinStringBuf(&target_buf, &parts, .auto);
@as([*]u8, @ptrFromInt(@intFromPtr(joined.ptr)))[joined.len] = 0;
var joined_: [:0]const u8 = joined.ptr[0..joined.len :0];
var child_dir = bun.openDir(dir, joined_) catch |err| {
this.err = err;
return;
};
defer child_dir.close();
var iter = child_dir.iterate();
var basedir_path = bun.getFdPath(child_dir.dir.fd, &target_buf) catch |err| {
this.err = err;
return;
};
target_buf[basedir_path.len] = std.fs.path.sep;
var target_buf_remain = target_buf[basedir_path.len + 1 ..];
var prev_target_buf_remain = target_buf_remain;
while (iter.next() catch null) |entry_| {
const entry: std.fs.IterableDir.Entry = entry_;
switch (entry.kind) {
std.fs.IterableDir.Entry.Kind.sym_link, std.fs.IterableDir.Entry.Kind.file => {
target_buf_remain = prev_target_buf_remain;
bun.copy(u8, target_buf_remain, entry.name);
target_buf_remain = target_buf_remain[entry.name.len..];
target_buf_remain[0] = 0;
var from_path: [:0]u8 = target_buf[0 .. @intFromPtr(target_buf_remain.ptr) - @intFromPtr(&target_buf) :0];
var to_path = if (!link_global)
std.fmt.bufPrintZ(&dest_buf, dot_bin ++ "{s}", .{entry.name}) catch continue
else
std.fmt.bufPrintZ(&dest_buf, "{s}", .{entry.name}) catch continue;
this.setSimlinkAndPermissions(from_path, to_path);
},
else => {},
}
}
},
}
}
pub fn unlink(this: *Linker, link_global: bool) void {
var target_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var dest_buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var from_remain: []u8 = &target_buf;
var remain: []u8 = &dest_buf;
if (!link_global) {
target_buf[0..dot_bin.len].* = dot_bin.*;
from_remain = target_buf[dot_bin.len..];
dest_buf[0.."../".len].* = "../".*;
remain = dest_buf["../".len..];
} else {
if (this.global_bin_dir.fd >= std.math.maxInt(std.os.fd_t)) {
this.err = error.MissingGlobalBinDir;
return;
}
@memcpy(target_buf[0..this.global_bin_path.len], this.global_bin_path);
from_remain = target_buf[this.global_bin_path.len..];
from_remain[0] = std.fs.path.sep;
from_remain = from_remain[1..];
const abs = bun.getFdPath(this.root_node_modules_folder, &dest_buf) catch |err| {
this.err = err;
return;
};
remain = remain[abs.len..];
remain[0] = std.fs.path.sep;
remain = remain[1..];
this.root_node_modules_folder = this.global_bin_dir.fd;
}
const name = this.package_name.slice();
bun.copy(u8, remain, name);
remain = remain[name.len..];
remain[0] = std.fs.path.sep;
remain = remain[1..];
if (comptime Environment.isWindows) {
@compileError("Bin.Linker.unlink() needs to be updated to generate .cmd files on Windows");
}
switch (this.bin.tag) {
.none => {
if (comptime Environment.isDebug) {
unreachable;
}
},
.file => {
// we need to use the unscoped package name here
// this is why @babel/parser would fail to link
const unscoped_name = unscopedPackageName(name);
bun.copy(u8, from_remain, unscoped_name);
from_remain = from_remain[unscoped_name.len..];
from_remain[0] = 0;
var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0];
std.os.unlinkatZ(this.root_node_modules_folder, dest_path, 0) catch {};
},
.named_file => {
var name_to_use = this.bin.value.named_file[0].slice(this.string_buf);
bun.copy(u8, from_remain, name_to_use);
from_remain = from_remain[name_to_use.len..];
from_remain[0] = 0;
var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0];
std.os.unlinkatZ(this.root_node_modules_folder, dest_path, 0) catch {};
},
.map => {
var extern_string_i: u32 = this.bin.value.map.off;
const end = this.bin.value.map.len + extern_string_i;
const _from_remain = from_remain;
const _remain = remain;
while (extern_string_i < end) : (extern_string_i += 2) {
from_remain = _from_remain;
remain = _remain;
const name_in_terminal = this.extern_string_buf[extern_string_i];
const name_in_filesystem = this.extern_string_buf[extern_string_i + 1];
var target = name_in_filesystem.slice(this.string_buf);
if (strings.hasPrefix(target, "./")) {
target = target[2..];
}
bun.copy(u8, remain, target);
remain = remain[target.len..];
remain[0] = 0;
remain = remain[1..];
var name_to_use = name_in_terminal.slice(this.string_buf);
bun.copy(u8, from_remain, name_to_use);
from_remain = from_remain[name_to_use.len..];
from_remain[0] = 0;
var dest_path: [:0]u8 = target_buf[0 .. @intFromPtr(from_remain.ptr) - @intFromPtr(&target_buf) :0];
std.os.unlinkatZ(this.root_node_modules_folder, dest_path, 0) catch {};
}
},
.dir => {
var target = this.bin.value.dir.slice(this.string_buf);
if (strings.hasPrefix(target, "./")) {
target = target[2..];
}
var parts = [_][]const u8{ name, target };
bun.copy(u8, remain, target);
remain = remain[target.len..];
var dir = std.fs.Dir{ .fd = this.package_installed_node_modules };
var joined = Path.joinStringBuf(&target_buf, &parts, .auto);
@as([*]u8, @ptrFromInt(@intFromPtr(joined.ptr)))[joined.len] = 0;
var joined_: [:0]const u8 = joined.ptr[0..joined.len :0];
var child_dir = bun.openDir(dir, joined_) catch |err| {
this.err = err;
return;
};
defer child_dir.close();
var iter = child_dir.iterate();
var basedir_path = bun.getFdPath(child_dir.dir.fd, &target_buf) catch |err| {
this.err = err;
return;
};
target_buf[basedir_path.len] = std.fs.path.sep;
var target_buf_remain = target_buf[basedir_path.len + 1 ..];
var prev_target_buf_remain = target_buf_remain;
while (iter.next() catch null) |entry_| {
const entry: std.fs.IterableDir.Entry = entry_;
switch (entry.kind) {
std.fs.IterableDir.Entry.Kind.sym_link, std.fs.IterableDir.Entry.Kind.file => {
target_buf_remain = prev_target_buf_remain;
bun.copy(u8, target_buf_remain, entry.name);
target_buf_remain = target_buf_remain[entry.name.len..];
target_buf_remain[0] = 0;
var to_path = if (!link_global)
std.fmt.bufPrintZ(&dest_buf, dot_bin ++ "{s}", .{entry.name}) catch continue
else
std.fmt.bufPrintZ(&dest_buf, "{s}", .{entry.name}) catch continue;
std.os.unlinkatZ(
this.root_node_modules_folder,
to_path,
0,
) catch continue;
},
else => {},
}
}
},
}
}
};
};