summaryrefslogtreecommitdiff
path: root/Source/Core/Common/FileUtil.cpp
diff options
context:
space:
mode:
authorJonathan Hamilton <jtrhamilton@gmail.com>2017-08-17 09:13:16 -0700
committerJonathan Hamilton <jtrhamilton@gmail.com>2017-08-17 14:08:56 -0700
commit643b3ba9f8a091b4e927b63c028e6e145d549268 (patch)
tree363aafd5f83af5d4ede47c46cd009f7cda857266 /Source/Core/Common/FileUtil.cpp
parent4e40fad248db3dccad901cd200dbc96c03bfbb7f (diff)
Try to fix File::Copy with non-1024-byte aligned sizes
ifstream::read() sets the failbit if trying to read over the end, which means that (!input) would be hit for the 'last' block if it wasn't exactly BSIZE (1024) bytes.
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
-rw-r--r--Source/Core/Common/FileUtil.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index 6f8e3a8b24..a848a68c98 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -354,7 +354,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename)
while (!input.eof())
{
// read input
- input.read(buffer, BSIZE);
+ auto read_size = input.readsome(buffer, BSIZE);
if (!input)
{
ERROR_LOG(COMMON, "Copy: failed reading from source, %s --> %s: %s", srcFilename.c_str(),
@@ -363,7 +363,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename)
}
// write output
- if (!output.WriteBytes(buffer, BSIZE))
+ if (!output.WriteBytes(buffer, read_size))
{
ERROR_LOG(COMMON, "Copy: failed writing to output, %s --> %s: %s", srcFilename.c_str(),
destFilename.c_str(), GetLastErrorMsg().c_str());