Skip to content

Commit

Permalink
Switch to using std::ios::ate
Browse files Browse the repository at this point in the history
  • Loading branch information
piepie62 committed Dec 16, 2018
1 parent 2b13486 commit 5bf8113
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions source/gui/screen/ScriptScreen.cpp
Expand Up @@ -255,10 +255,9 @@ static std::pair<u8*, size_t> scriptRead(std::string path)
{
u8* data = nullptr;
size_t size = 0;
std::ifstream in(path, std::ios::binary);
std::ifstream in(path, std::ios::binary | std::ios::ate);
if (in.good())
{
in.seekg(0, std::ios::end);
size = in.tellg();
in.seekg(0, std::ios::beg);
data = new u8[size];
Expand Down
3 changes: 1 addition & 2 deletions source/mysterygift.cpp
Expand Up @@ -35,8 +35,7 @@ void MysteryGift::init(Generation g)
sheet >> mysteryGiftSheet;
sheet.close();

std::ifstream data(StringUtils::format("romfs:/mg/data%s.bin", genToString(g).c_str()), std::ios::binary);
data.seekg(0, std::ios::end);
std::ifstream data(StringUtils::format("romfs:/mg/data%s.bin", genToString(g).c_str()), std::ios::binary | std::ios::ate);
size_t size = data.tellg();
data.seekg(0, std::ios::beg);

Expand Down
6 changes: 2 additions & 4 deletions source/sav/Bank.cpp
Expand Up @@ -36,9 +36,8 @@ Bank::Bank()
if (io::exists("/3ds/PKSM/bank/bank.bin"))
{
bool deleteOld = true;
std::ifstream in("/3ds/PKSM/bank/bank.bin");
std::ifstream in("/3ds/PKSM/bank/bank.bin", std::ios::binary | std::ios::ate);
Gui::waitFrame(i18n::localize("BANK_CONVERT"));
in.seekg(0, std::ios::end);
size_t oldSize = in.tellg();
in.seekg(0, std::ios::beg);
u8* oldData = new u8[oldSize];
Expand Down Expand Up @@ -240,11 +239,10 @@ void Bank::loadExtData()
void Bank::loadSD()
{
bool needResize = false, needSave = false;
std::fstream in("/3ds/PKSM/banks/pksm_1.bnk", std::ios::in);
std::fstream in("/3ds/PKSM/banks/pksm_1.bnk", std::ios::in | std::ios::binary | std::ios::ate);
if (in.good())
{
Gui::waitFrame(i18n::localize("BANK_LOAD"));
in.seekg(0, std::ios::end);
size = in.tellg();
in.seekg(0, std::ios::beg);
data = new u8[size];
Expand Down

0 comments on commit 5bf8113

Please sign in to comment.