Re: File Module: $target in file:copy()

>   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?

This is how file:copy and file:move is actually specified in the
latest spec: “if $target is a directory, the source directory with all
its files will be copied into the target directory”. [1] Or did I get
you wrong? If you believe that the wording is misleading, feel free to
propose a revised version.

>   2) Furthermore, I wonder whether we should not rather use the
> convention that directories are identified by a trailing slash.

This clearly sounds like the cleaner solution, and it makes completely
sense in the Archive Module, in which the representation is a
main-memory one. However, I would be careful to realize it for file
operations. As soon as we operate on disk, we’ll end up with
non-deterministic operations anyway, so I believe the use will be
limited. Instead, we’d have to add various error checks to cover cases
in which the string syntax does not match the actual operation (e.g.:
file:create-dir("abc") ).

But I appreciate your feedback and will think more about it.

Christian

[1] http://expath.org/spec/file/20131129

Received on Monday, 2 December 2013 17:43:44 UTC