File Module: $target in file:copy()

  Hi,

  Reading again the definition of file:copy [1], I have 2 comments.

  1) Why is there a difference in the way we handle files and
directories, in case the target exists and is a directory?  If the
source is a file, it is copied in the target dir, it is is a dir, its
children (files and dirs) are copied in the target dir.

  Why do not copy the directory itself in the latter case?  I think
this is what recursive (because operating on directories) operations
usually do.  It would also make the definition simpler, and does not
need to differentiate both cases (whether source is a file or a dir).

  2) Furthermore, I wonder whether we should not rather use the
convention that directories are identified by a trailing slash.  That
would get rid of any ambiguity.  And more importantly, the semantics
of the call would not depend on the state of the file system (in the
current definition, what a call will result in depends on the state of
the file system, whether target exists or not, and whether it is a
directory if it exists).

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/

[1] http://expath.org/spec/file#d3e585

Received on Monday, 2 December 2013 17:25:45 UTC