import path from '#host-path' /** * Map a path relative to the host `kernel/` tree to the POSIX path on the system image. * @param {string} subRel native-relative path (e.g. `bin/cat`, `init.js`) * @returns {string} image path starting with `/` */ export function kernelHostRelToImagePosix(subRel) { if (subRel === 'init.js') return '/boot/init.js' if (subRel.startsWith('bin' + path.sep)) { return '/bin/' + subRel.slice(4).split(path.sep).join('/') } if (subRel.startsWith('etc' + path.sep)) { return '/etc/' + subRel.slice(4).split(path.sep).join('/') } return '/' + subRel.split(path.sep).join('/') } export function skipKernelImagePath(drivePath) { return drivePath === '/README.md' } /** * `/kernel/bin/cat` → host-relative `bin/cat` (native separators). * @param {string} fullKey hyperdrive key * @returns {string | null} */ export function bundleKernelKeyToHostRel(fullKey) { const k = String(fullKey).replace(/^\/+/, '') if (!k.startsWith('kernel/')) return null const rest = k.slice('kernel/'.length) if (!rest) return null return rest.split('/').join(path.sep) }