@ai-ecoverse/slicc-kernel 1.56.1 → 1.56.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.js CHANGED
@@ -2542,12 +2542,34 @@ var OpfsFs = class {
2542
2542
  const link2 = await this.linkAlong(current);
2543
2543
  if (!link2) throw err;
2544
2544
  if (link2.path === current && !follow2) return { path: current, link: link2 };
2545
- const rest2 = current.slice(link2.path.length);
2546
- current = resolvePath(parentOf2(link2.path), `${link2.link}${rest2}`);
2545
+ const target = `${link2.link}${current.slice(link2.path.length)}`;
2546
+ current = target.split("/").includes("..") ? await this.physical(parentOf2(link2.path), target, hops + 1) : resolvePath(parentOf2(link2.path), target);
2547
2547
  }
2548
2548
  }
2549
2549
  throw fsError("ELOOP", path);
2550
2550
  }
2551
+ async physical(base, path, used) {
2552
+ let done4 = [];
2553
+ let todo = (path.startsWith("/") ? path : `${base}/${path}`).split("/").filter((p) => p !== "" && p !== ".");
2554
+ for (let hops = used; todo.length > 0; ) {
2555
+ const part = todo.shift();
2556
+ if (part === "..") done4.pop();
2557
+ else if (!todo.includes("..")) done4.push(part);
2558
+ else {
2559
+ const at = `/${[...done4, part].join("/")}`;
2560
+ const st = await this.lstat(at);
2561
+ if (!st.isSymbolicLink && !st.isDirectory) throw fsError("ENOTDIR", at);
2562
+ if (!st.isSymbolicLink) done4.push(part);
2563
+ else if (++hops > MAX_LINKS2) throw fsError("ELOOP", path);
2564
+ else {
2565
+ const link2 = await this.readlink(at);
2566
+ if (link2.startsWith("/")) done4 = [];
2567
+ todo = [...link2.split("/").filter((p) => p !== "" && p !== "."), ...todo];
2568
+ }
2569
+ }
2570
+ }
2571
+ return `/${done4.join("/")}`;
2572
+ }
2551
2573
  mode(path, directory, meta) {
2552
2574
  const fallback = directory || EXECUTABLE.test(path) ? 493 : 420;
2553
2575
  return (directory ? S_IFDIR : S_IFREG) | (meta?.mode ?? fallback);
@@ -9386,6 +9408,11 @@ var MAX_LINKS5 = 40;
9386
9408
  function parentOf6(path) {
9387
9409
  return path.slice(0, path.lastIndexOf("/")) || "/";
9388
9410
  }
9411
+ async function mustBeDir(fs, path) {
9412
+ if (!fs.lstat) return;
9413
+ const st = await fs.lstat(path);
9414
+ if (st.isDirectory !== true) throw fsError("ENOTDIR", path);
9415
+ }
9389
9416
  async function linkOf(fs, path) {
9390
9417
  return fs.readlink?.(path).catch(() => void 0);
9391
9418
  }
@@ -9402,6 +9429,7 @@ async function realDir(fs, dir, budget = { hops: 0 }) {
9402
9429
  const next2 = at === "/" ? `/${part}` : `${at}/${part}`;
9403
9430
  const link2 = await linkOf(fs, next2);
9404
9431
  if (link2 === void 0) {
9432
+ if (queue.find((p) => p !== ".") === "..") await mustBeDir(fs, next2);
9405
9433
  at = next2;
9406
9434
  continue;
9407
9435
  }