From ffe628f29ac9e35b74031cc20222ca26df9c33c0 Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Sat, 25 Jul 2009 08:32:21 +0000 Subject: [PATCH] Move tellg() usage to the start of the block rather than at the end, otherwise it would always return -1. This should be harmless for windows. Originally committed to SVN as r3269. --- aegisub/tools/common-respack.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aegisub/tools/common-respack.cpp b/aegisub/tools/common-respack.cpp index 8949e1ba9..4ceb283d9 100644 --- a/aegisub/tools/common-respack.cpp +++ b/aegisub/tools/common-respack.cpp @@ -128,6 +128,10 @@ int main(int argc, const char *argv[]) { while (iter.Next(&filename)) { ifstream infile(filename.char_str(), ios::binary); + infile.seekg(0, ios::end); + int infile_end = infile.tellg(); + infile.seekg(0, ios::beg); + wxFileName file(filename); wxString identifier = file.GetName() + "_" + file.GetDirs().Last(); nameCleaner.ReplaceAll(&identifier, "_"); @@ -141,8 +145,7 @@ int main(int argc, const char *argv[]) { first = false; } outC << "};" << endl; - infile.seekg(ios_base::end); - outH << "extern const unsigned char " << identifier << "[" << infile.tellg() << "];" << endl; + outH << "extern const unsigned char " << identifier << "[" << infile_end << "];" << endl; } return 0;