Skip to content

Node: loadPath(file) loads a loose SerializedFile's m_Externals from disk #165

Closed

Description

@fatal10110

Package: packages/node (npm unity-asset-reader-node)

Description

loadPath(file) (#43, PR #161) loads a single file with its own .resS / .resource sidecars and nothing else from its directory. Upstream's LoadAssetsFile also reads, from disk, the files that a loose SerializedFile names in m_Externals (for example sharedassets1.assets next to sharedassets0.assets), so cross-file PPtrs resolve without the caller passing the whole directory. Today a caller has to pass the directory for that. Plan §M5 limits #43 to the fs read / dir scan / split merge / sidecar slice, so this is new behaviour and M6+ material, worth doing only if a consumer needs it. Raised in the review of PR #161 (#161, review body, Follow-ups finding).

Tasks

  • In loadPath(file), read the files named in each loose SerializedFile's m_Externals (with their sidecars, split parts merged) from the same directory and load them together with the file.
  • Look only next to the file, as upstream does; never scan subfolders. Skip names already loaded.
  • A missing external is not an error (upstream skips it); an unreadable one throws Node's error, as the rest of loadPath does.
  • Use only core's public API (R14). If the externals list is not reachable through it, stop and ask for a plan decision instead of deep-importing.

Port

AssetStudio/AssetsManager.cs (LoadAssetsFile: the loop over assetsFile.m_Externals that adds files from the same directory to importFiles).

Acceptance

  • A folder holding sharedassets0.assets that references sharedassets1.assets: loadPath(".../sharedassets0.assets") loads both files (plus their sidecars), and a PPtr from the first into the second resolves.
  • A file whose external is missing still loads, with that PPtr unresolved.

Plan: docs/unity-asset-reader-plan.md. Behavior source of truth: Razviar/assetstudio (MIT). Golden oracle: UnityPy (MIT). MIT-derivative port: keep upstream copyright notices. Do not copy or import @arkntools/unity-js (AGPL-3.0), tests included. No C# compiled to WASM - C# is reference only, hand-ported to TS; WASM is built from C/C++ only (plan D2). Layout: npm-workspaces monorepo under packages/; dependencies point feature package -> core only (plan D7/D8, rules R13/R14).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:nodeNode.js adapterbacklogOn-demand, no named consumer yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions