Bug 15865 – std.file.copy(from,to) deletes the file if from and to specify the same file

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-04-03T04:23:00Z
Last change time
2016-04-04T16:51:21Z
Keywords
pull
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2016-04-03T04:23:02Z
It does this because on non-Windows systems, the implementation creates the 'to' file before reading the 'from' file. Severity bumped to 'major' because deleting files is not nice.
Comment #1 by dlang-bugzilla — 2016-04-04T14:18:45Z
Comment #2 by github-bugzilla — 2016-04-04T16:51:20Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/fad13881996fabbf06704ac5a42b0f843f54630c fix Issue 15865 - std.file.copy(from,to) deletes the file if from and to specify the same file Stat the target fd and check for sameness before truncating the file. https://github.com/D-Programming-Language/phobos/commit/df99fc87075c46cefb4a6a6052056b833fb93c93 Merge pull request #4148 from CyberShadow/pull-20160404-141544 fix Issue 15865 - std.file.copy(from,to) deletes the file if from and to specify the same file