mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-08 17:48:46 -10:00
* add subfolder support to cfile * sort files in VP archives before indexing them * fix indexing of sub-subfolders * remove unused 8B22K & 16B11K sound path types * add more items to skip subfolder scanning * fix windows build issues * fix unit tests by allowing 0-byte files to be indexed * fix file indexing on windows * add test for cfile subfolders * remove specific 'markup' and 'css' interface subfolders They aren't directly referenced anywhere by pathtype and the new subfolder code will continue to index and load files from them * add player binds to list of always-root locations * remove file-based localization support An alternative is left in place for old fonts, as that was the only place it appeared to be used. This method of file localization conflicts with subfolder support however so if it's needed in the future then changes to the subfolder code will be necessary. * add subfolder support to cf_find_file_location_ext() * add subfolder tests for cf_find_file_location*() * add shlwapi to needed win32 libs * small bit of cleanup * add subfolder support to cf_get_file_list() * add tests for cfile subfolder lists * report files that might be shadowed * fix issue with lists when a filter is used Also fixes discrepancy in older cf_get_file_list() when a sub path is specified (should be used in all cases, not just glob). * address review suggestions
37 lines
701 B
Lua
37 lines
701 B
Lua
local exts = {
|
|
"",
|
|
".lua",
|
|
".lc"
|
|
}
|
|
|
|
local function cfileLoader(name)
|
|
local file = nil
|
|
|
|
for i,v in ipairs(exts) do
|
|
local real_name = string.gsub(name, "%.", "/") .. v
|
|
file = cf.openFile(real_name, "r", "data/scripts")
|
|
|
|
if (file:isValid()) then
|
|
name = real_name
|
|
break;
|
|
end
|
|
end
|
|
|
|
if (file == nil or not file:isValid()) then
|
|
return "Module '" .. name .. "' is not known by the CFile system"
|
|
end
|
|
|
|
local content = file:read("*a")
|
|
file:close()
|
|
|
|
local func, err = loadstring(content, name)
|
|
|
|
if err then
|
|
return err
|
|
end
|
|
|
|
return func
|
|
end
|
|
|
|
table.insert(package.loaders, 2, cfileLoader)
|