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

On 4 December 2013 16:00, Christian Grün wrote:

>> |>   b. if $target is a directory, the source directory with all
>> |>      its files will be copied into the target directory.  At
>> |>      each level, if a file already exists in the target with the
>> |>      same name as in the source, it is overwritten.  If a
>> |>      directory already exists in the target with the same name
>> |>      as in the source, it is not removed, it is recursed in
>> |>      place (if it does not exist, it is created before
>> |>      recursing).

> Sounds fine to me.

  I have just committed the change.

  I was going to apply the same change to bin:move, then thought that
it is not as some systems behave (at least in the world of Unix-like
shells, including Linux and Mac OS X).

  If I understand correctly the wording, it is meant to make a
recursive copy, then remove the source.  But in Unix-like systems,
when moving a dir, only its name change, there is no other I/Os.  On
those systems, moving a dir foo to an existing dir bar, with a subdir
foo (the same name) is an error.

  Do we really want to make a "merging" copy in that case?  Instead of
an error?  Suggested change, in bin:move:

|>   b. if $target is a directory, the source directory with all its
|>      files will be moved into the target directory. If a file
|>      already exists, it will be overwritten.

to:

|>   b. if $target is a directory, the source directory with all its
|>      files will be moved into the target directory. If the target
|>      directory contains a directory with the same name as the
|>      source, the error [err:FILE0004] is raised.

and later, change:

|>  [err:FILE0004] is raised if $source points to a file and $target
|>  points to a directory, in which a subdirectory exists with the
|>  name of the source file.

to:

|>  [err:FILE0004] is raised if $target points to a directory, in
|>  which a subdirectory exists with the name of the source.

  Regards,

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

Received on Wednesday, 4 December 2013 23:45:59 UTC