diff options
author | João Abecasis <joao@abecasis.name> | 2009-04-15 12:17:20 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-05-22 12:33:38 (GMT) |
commit | 562adecf4f938f593674f03b425a79b89e238518 (patch) | |
tree | 138b25d24fb4d51ddd41c2790917eca3280d3a8e /src/corelib | |
parent | 1cfb5bcaa2cab142479ee975e25d9f605f852dad (diff) | |
download | Qt-562adecf4f938f593674f03b425a79b89e238518.zip Qt-562adecf4f938f593674f03b425a79b89e238518.tar.gz Qt-562adecf4f938f593674f03b425a79b89e238518.tar.bz2 |
Don't block copy sequential files in QFile::rename
Block copying a sequential file is potentially a destructive operation,
because there is no guarantee copy+remove will succeed. In these cases
the fallback should not be tried.
The user is better equipped to decide how to handle such failures and to
ensure no data losses occur, e.g., copy without removing the original
file.
Reviewed-by: MariusSO
Reviewed-by: Peter Hartmann
Reviewed-by: Thiago
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfile.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index d7da800..4110494 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -718,6 +718,11 @@ QFile::rename(const QString &newName) return true; } + if (isSequential()) { + d->setError(QFile::RenameError, tr("Will not rename sequential file using block copy")); + return false; + } + QFile in(fileName()); QFile out(newName); if (in.open(QIODevice::ReadOnly)) { |