参考所有分组:完善OPFS参数备份桥接
结论:按 LinuxCNC rs274ngc_pre.cc save_parameters()/restore_parameters() 语义,补齐浏览器 OPFS 参数文件 .bak 持久化;未扩展 smoke 解析行为。 验证:./test-native.sh;./test-linuxcnc-source-link.sh;./test-web-wasm-node-smoke.sh;./test-web-wasm-browser-smoke.sh。
This commit is contained in:
@@ -703,10 +703,19 @@ export async function createWasmSimulator(moduleOptions = {}) {
|
||||
throw new Error("OPFS workspace is not available for parameter file persistence");
|
||||
}
|
||||
cleanupLinuxCncParameterFiles(module);
|
||||
await opfs.loadParameterFile(parameterPath);
|
||||
const previousParameterFile = await opfs.loadParameterFile(parameterPath);
|
||||
try {
|
||||
const events = parseText(program, dialect, options, { keepLinuxCncParameterFiles: true });
|
||||
await opfs.persistParameterFile(parameterPath);
|
||||
// LinuxCNC source basis: rs274ngc_pre.cc save_parameters()
|
||||
// links the previous parameter file to filename + ".bak" before
|
||||
// replacing filename. Browser filesystems may not expose that link
|
||||
// through the WASM mirror, so preserve the loaded OPFS file here.
|
||||
if (previousParameterFile === null) {
|
||||
await opfs.removeFile(`${parameterPath}.bak`);
|
||||
} else if (!(await opfs.exists(`${parameterPath}.bak`))) {
|
||||
await opfs.writeFile(`${parameterPath}.bak`, previousParameterFile);
|
||||
}
|
||||
return events;
|
||||
} finally {
|
||||
cleanupLinuxCncParameterFiles(module);
|
||||
|
||||
Reference in New Issue
Block a user