Codereview comments from r1685
This commit is contained in:
parent
bf85a92f54
commit
1dbb1817e8
|
@ -28,6 +28,8 @@
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/scoped_array.hpp>
|
||||||
|
|
||||||
namespace Utilities {
|
namespace Utilities {
|
||||||
|
|
||||||
static QString tr(const char* str) {
|
static QString tr(const char* str) {
|
||||||
|
@ -144,35 +146,28 @@ bool Copy(QIODevice* source, QIODevice* destination) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const qint64 bytes = source->size();
|
const qint64 bytes = source->size();
|
||||||
char* data = new char[bytes];
|
boost::scoped_array<char> data(new char[bytes]);
|
||||||
qint64 pos = 0;
|
qint64 pos = 0;
|
||||||
|
|
||||||
forever {
|
qint64 bytes_read;
|
||||||
const qint64 bytes_read = source->read(data + pos, bytes - pos);
|
do {
|
||||||
if (bytes_read == -1) {
|
bytes_read = source->read(data.get() + pos, bytes - pos);
|
||||||
delete[] data;
|
if (bytes_read == -1)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
pos += bytes_read;
|
pos += bytes_read;
|
||||||
if (bytes_read == 0 || pos == bytes)
|
} while (bytes_read > 0 && pos != bytes);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
forever {
|
qint64 bytes_written;
|
||||||
const qint64 bytes_written = destination->write(data + pos, bytes - pos);
|
do {
|
||||||
if (bytes_written == -1) {
|
bytes_written = destination->write(data.get() + pos, bytes - pos);
|
||||||
delete[] data;
|
if (bytes_written == -1)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
pos += bytes_written;
|
pos += bytes_written;
|
||||||
if (bytes_written == 0 || pos == bytes)
|
} while (bytes_written > 0 && pos != bytes);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] data;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue