Whoops to that. It's probably too late to update the io library. OTOH, I'm not sure if I want the entire Lua IO library available for general consumption; it makes it possible to rename and delete files on other portions of the hard drive, which makes scripting much more of a risk on Windows computers, or other OSes with lax filesystem security. Not appropriate for a game scripting system at all.
CFile, on the other hand, has a number of issues. First, it has problems when you try to look for file types that aren't hardcoded as enabled. Thus, you can do fileExists() on an ogg in the root directory or a mod directory and it'll come up positive, but if you try it with a .tbm, it won't work. Similarly, if you make your own filetypes, CFile just won't deal with them; although it'll probably open them for writing.
Another problem with CFile is that when doing rename, write, etc. - basically any operation, really, but the ones that make changes are the most critical - you can't specify which directory it happens in. Thus, you can run fileExists() on a .ogg in the main directory, but if you try to rename it, it'll try to rename it as if it existed in your primary mod directory - and promptly fail. The same problem exists for deleteFile().
So two things need to be done with CFile:
- Enable support for other file extensions beyond the hardcoded ones. (This limitation exists to speed up indexing)
It looks like this is possible on a limited basis using the _ext functions that Goober added. I'll have to update some internal CFile functions, but nothing core or critical to the rest of the system.
- Modify the rename and delete functions to support mods properly.
This looks a bit more difficult. Probably involving a new function or changes to critical functions like cf_create_default_path_string to (a) work in the same precedence as the exists function, and (b) allow you to specify the mod folder (For things like opening files and creating directories)