It would be helpful if files in the cache could be accessed at runtime by filename. This would allow for storing file names in savefiles, instead of saving the entire file or hard-coding an associative-list of file cache references ("turfs.dmi"='turfs.dmi', "dragon.dmi"='dragon.dmi', ect).
For my purposes, I'm working on a map saver/loader, and would like to be able save any non-initial icon values without saving the entire icon or forcing the user to put together and maintain the aforementioned cache reference list. It would also allow for developers to write a clean process to save overlay data without flattening and saving the icon.
It has been suggested that file() be given a second parameter to specify if it's from the cache, but I think file_rsc(filename) would also be appropriate (and in-line with fcopy/fcopy_rsc).
Simple example use-case:
mob
icon='mob.dmi'
verb
SaveIcon()
var/savefile/S = new/savefile("test.sav")
S<<"[icon]"
LoadIcon()
var/savefile/S = new/savefile("test.sav")
var/filename
var/icon/I
S>>filename
I = file_rsc(filename)
if(I)
src.icon = I
else
src<<"File '[filename]' no longer in cache!"
In the above example, I assume file_rsc() would return null if the file could not be found in the cache. I think this makes more sense then throwing an error, because files disappearing from the cache may be a common occurrence (ie for old savefiles), and there's no real way for a developer to avoid the error.