[Issue 3862] std.file.copy does not have the same behavior as cp

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Nov 3 11:51:48 PST 2015


https://issues.dlang.org/show_bug.cgi?id=3862

Vladimir Panteleev <thecybershadow at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
                 CC|                            |thecybershadow at gmail.com

--- Comment #6 from Vladimir Panteleev <thecybershadow at gmail.com> ---
We definitely DO NOT want to match the behavior of cp. cp is a tool primarily
aimed to be used directly by humans, hence some of its DWIM behavior and common
human mistake checks. std.file.copy is a function which will always be used as
part of a larger, more complicated program.

For example, copying a file into the subdirectory if the destination path is a
directory is something that would, IMO, violate the principle of least
surprise. In most circumstances, the program will know if the destination path
should be a file or directory (assuming it exists), and the programmer can
write the intended behavior anyway. If the program expects that the destination
path doesn't exist or is a file, but is in fact a directory, then putting the
file inside the directory is definitely not something the programmer should
need to foresee and take into account for.

What we could draw comparisons with is how other programming languages'
standard libraries do it. At this point, it might be too late to change the
behavior of std.file.copy at all.

--


More information about the Digitalmars-d-bugs mailing list