D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15330 - std.file.copy outputs wrong error message when target directory doesn't exist
Summary: std.file.copy outputs wrong error message when target directory doesn't exist
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-13 20:03 UTC by lbach
Modified: 2015-11-16 01:51 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description lbach 2015-11-13 20:03:05 UTC
The following program works as expected because both the source file and the destination directory exist:

import std.file;

void main() {
	copy("/home/master/temp/foo.txt", "/home/master/foo.txt");
}

Changing the second argument to this:

import std.file;

void main() {
	copy("/home/master/temp/foo.txt", "/home/master/baz/foo.txt");
}

causes the program to fail because there is no /home/master/baz directory. But the error message is

std.file.FileException@std/file.d(2315): /home/master/temp/foo.txt: No such file or directory

That's confusing because the file does exist. The correct message would be

std.file.FileException@std/file.d(2315): /home/master/temp: No such directory
Comment 1 Infiltrator 2015-11-16 01:51:47 UTC
This has been fixed in 2.069:

std.file.FileException@std/file.d(3139): baz/bar.txt: No such file or directory

=========
import std.file;

void main() {
   write("foo.txt", "abc");
   copy("foo.txt", "baz/bar.txt");
}
=========