Skip to content

Conversation

@hydrogen-mvm
Copy link
Contributor

Here is a snippet from the current TF2 event I'm working on:

g_FlatFile.WriteLine("wave,%d,%d,%d,%d", Steam3, TimeStamp, MissionIndex, WaveNumber);
FlushFile(g_FlatFile);

I would like to be able to flush the file like this so that I can consistently use methodmaps on the file handle instead of flip flopping between legacy and new API:

g_FlatFile.WriteLine("wave,%d,%d,%d,%d", Steam3, TimeStamp, MissionIndex, WaveNumber);
g_FlatFile.Flush();

Here is a patch (one for smn_filesystem.cpp and one for files.inc) that adds the Flush method to the file methodmap. Please review and let me know if I accidentally broke something or violated any coding conventions. I don't have a C++ compiler so I wasn't able to test if this will break the buildbots or CI.

Thanks.

This allows us to do FileHandle.Flush() instead of FlushFile(FileHandle) and maintain consistency in always using methodmaps for file I/O operations.
@psychonic
Copy link
Member

Definitely looks like it was an oversight. Thanks!

@psychonic psychonic merged commit 22635d8 into alliedmodders:master Jul 31, 2019
BotoX pushed a commit to BotoX/sourcemod that referenced this pull request Sep 10, 2019
This allows us to do FileHandle.Flush() instead of FlushFile(FileHandle) and maintain consistency in always using methodmaps for file I/O operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants