sourcemod
sourcemod copied to clipboard
Implement File.Size
Can you add please .Size property to "File" methodmap?
Same as: https://sm.alliedmods.net/new-api/files/FileSize
FileSize
is a stat
call rather than operating on an open file (which is why it takes a path string rather than a file handle), so I'm not sure it is the best fit for a File methodmap property, and it'll be more expensive than properties generally are. That said, we could probably use the already open FD to reduce the perf impact, and it looks like IBaseFileSystem
has an equiv for that as well - so maybe that rather different implementation would be a good fit.
The other option of course is you can do the usual C seek/tell dance:
File test = OpenFile("test.txt", "r");
test.Seek(0, SEEK_END);
int size = test.Position;
test.Seek(0, SEEK_SET);