diff --git a/script/fs-utility.lua b/script/fs-utility.lua index 46e411711..b57c15bbb 100644 --- a/script/fs-utility.lua +++ b/script/fs-utility.lua @@ -254,6 +254,7 @@ function dfs:saveFile(path, text) return false, '无法打开:' .. path end dir[filename] = text + return true end ---@param path string|fs.path diff --git a/script/library.lua b/script/library.lua index 57aac066f..208b10edb 100644 --- a/script/library.lua +++ b/script/library.lua @@ -243,14 +243,25 @@ local function initBuiltIn(uri) if status == 'disable' then goto CONTINUE end - libName = libName .. '.lua' + ---@type fs.path - local libPath = templateDir / libName + local libPath = templateDir / (libName .. '.lua') local metaDoc = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status) if metaDoc then metaDoc = encoder.encode(encoding, metaDoc, 'auto') - out:saveFile(libName, metaDoc) - local outputPath = metaPath / libName + + local outputLibName = libName:gsub('%.', '/') .. '.lua' + if outputLibName ~= libName then + out:createDirectories(fs.path(outputLibName):parent_path()) + end + + local ok, err = out:saveFile(outputLibName, metaDoc) + if not ok then + log.debug("Save Meta File:", err) + goto CONTINUE + end + + local outputPath = metaPath / outputLibName m.metaPaths[outputPath:string()] = true log.debug('Meta path:', outputPath:string()) end