octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Re: Problem using copyfile and movefile


From: John W. Eaton
Subject: RE: Re: Problem using copyfile and movefile
Date: Tue, 27 Feb 2007 10:29:52 -0500

On 27-Feb-2007, address@hidden wrote:

| >> 1) modify .m files to perform element-wise copy/move through a for loop:
| >> quite slow, but should work; easy to implement
| >> 2) do not rely on underlying cp/mv tools and implement it completely with
| >> octave tools: lot of work; portable; should probably be done in C++ for
| >> speed, using file_ops, file_stat and dir_entry
| >> 3) include cp.exe and mv.exe in octave distribution (MSVC): I'm not really
| >> in favor of that
| >
| > Hey you answered your own question -> 2) ....
| 
| Well, I biased the things a little bit... :-)
| I'm indeed in favor of 2, because of portability. OTOH, this also means
| somehow re-inventing the wheel, which some people might mot agree
| upon.
| 
| > Seriously, is it that much work?
| 
| Not for only basic support. But if you want to support all \"cp\" features,
| then it might be cumbersome. With the abstraction layer that octave
| provides, you can already do a good job.

It would be OK to have these as built-in functions, but I think some
care is needed to implement them.  You need to be careful about read
and write errors and possibly preserving access and modification time
stamps.  Also, moving a file should be done with rename if possible
(only works if source and target files are on the same filesystem) but
should still work by copy and remove if not (and in that case, you
definitely must be careful about open/read/write/close errors).  All
these little details add up to the reason that I chose to use cp and
mv, which presumably have all the bugs worked out.

Rather than inventing a solution just for Octave, I think it would
probably be good to use gnulib for these kinds of things, and to
enhance gnulib if there is some missing functionality.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]