[Issue 17241] New: std.file.rename exceptions should include both 'from' and 'to' file paths
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Mar 2 17:31:43 PST 2017
https://issues.dlang.org/show_bug.cgi?id=17241
Issue ID: 17241
Summary: std.file.rename exceptions should include both 'from'
and 'to' file paths
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: acehreli at yahoo.com
Currently, the exception message makes sense only if the problem is with the
'to' file path.
1) BAD CASE:
import std.file;
void main() {
rename("some_non_existing_file.txt", "bar.txt");
}
Unfortunately, the exception includes the target file name:
std.file.FileException at std/file.d(681): bar.txt: No such file or directory
[...]
DISCUSSION: The fix seems to be trivial by replacing the last argument with
fromz below:
phobos/std/file.d:681:
cenforce(core.stdc.stdio.rename(fromz, toz) == 0, t, toz);
However, it's not that simple because in some cases it's toz that needs to be
reported.
2) GOOD CASE:
import std.file;
void main() {
// Assuming that foo.txt exists:
rename("foo.txt", "some/non/existing/path/bar.txt");
}
std.file.FileException at std/file.d(681): some/non/existing/path/bar.txt: No such
file or directory
[...]
So, it makes sense to include both paths.
--
More information about the Digitalmars-d-bugs
mailing list