[erlang-bugs] Copying a file to itself

Jan Henry Nystrom jan@REDACTED
Fri Feb 29 11:00:46 CET 2008


Ulf Wiger (TN/EAB) wrote:
> John Hughes skrev:
>> Calling file:copy(Name,Name) to copy a file to itself truncates the file 
>> to 0 bytes. I’m not sure if this is a bug, but it isn’t what I 
>> expected—even after reading the documentation. 

I am sorry to say that I disagree. The documentation says that it will
open the files with [read, binary] and [write, binary] and the
write will truncate any existing file. So from the documentation
it is fairly clear that it will copy nothing since the file has been
opened with 'write'. If that is the right thing to do is a completely
different kettle of fish and do not personally have any opinions on
that.

But please keep applying QuickCheck on the standard libraries, it throws
all kinds googlies at it :-)


/Cheers Henry

>>Perhaps either file:copy 
>> should return an error in this case, or the documentation should mention 
>> this behaviour explicitly.
> 
> John,
> 
> You need to stop using QuickCheck on well tested libraries! ;-)
> 
> Let us keep *some* of our illusions of quality software.
> 
> Seriously, I'd be happy if file:copy(Name,Name) works just like in Unix, 
> i.e. it doesn't do anything, since the files are identical.
> 
> $> cp Makefile test
> $> ls -l test
> -r--r--r--   1 ....       2676 Feb 29 10:35 test
> $> cp test test
> cp: test and test are identical
> $> ls -l test
> -r--r--r--   1 ....       2676 Feb 29 10:35 test
> 
> 
> BR,
> Ulf W
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-bugs


-- 
Jan Henry Nystrom <jan@REDACTED>
Training Manager @ Erlang Training and Consulting Ltd
http://www.erlang-consulting.com



More information about the erlang-bugs mailing list