Created
July 20, 2018 20:57
-
-
Save zachhilman/5fc076ef4559aab4c7398455877e94c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string mode_str; | |
u32 mode_flags = static_cast<u32>(mode); | |
// Calculate the correct open mode for the file. | |
if ((mode_flags & static_cast<u32>(Mode::Read)) && | |
(mode_flags & static_cast<u32>(Mode::Write))) { | |
if (mode_flags & static_cast<u32>(Mode::Append)) | |
mode_str = "a+"; | |
else | |
mode_str = "r+"; | |
} else { | |
if (mode_flags & static_cast<u32>(Mode::Read)) | |
mode_str = "r"; | |
else if (mode_flags & static_cast<u32>(Mode::Append)) | |
mode_str = "a"; | |
else if (mode_flags & static_cast<u32>(Mode::Write)) | |
mode_str = "w"; | |
} | |
mode_str += "b"; | |
return mode_str; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment