Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add File.Flush methodmap #1056

Merged
merged 1 commit into from Jul 31, 2019
Merged

Add File.Flush methodmap #1056

merged 1 commit into from Jul 31, 2019

Conversation

hydrogen-mvm
Copy link
Contributor

@hydrogen-mvm hydrogen-mvm commented Jul 31, 2019

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

@psychonic psychonic commented Jul 31, 2019

Definitely looks like it was an oversight. Thanks!

@psychonic psychonic merged commit 22635d8 into alliedmodders:master Jul 31, 2019
2 checks passed
BotoX pushed a commit to BotoX/sourcemod that referenced this issue 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.

None yet

2 participants