Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: copying files |
| Date | 2012-02-16 09:54 -0800 |
| Organization | None to speak of |
| Message-ID | <ln4nuqhdf0.fsf@nuthaus.mib.org> (permalink) |
| References | <f62ccd5a-1cf4-4585-b8ca-c515a53d8a73@w9g2000vbv.googlegroups.com> <lnlio3glzu.fsf@nuthaus.mib.org> <74bd0e58-fa7d-43f0-9438-8192c8f706a0@s7g2000vby.googlegroups.com> |
Hans Vlems <hvlems@freenet.de> writes:
> On 16 feb, 10:34, Keith Thompson <ks...@mib.org> wrote:
[...]
>> I'd just invoke the OS's command to copy the files ("cp" on
>> Unix-like systems, "copy" on Windows, probably something else on
>> other systems). It's likely to be at least as fast as anything
>> you write yourself, and it may preserve metadata (permissions,
>> etc.) that you're not going to be able to handle in your own code
>> without considerable difficulty.
>>
>> I'm not sure why system running "out of control" of your program
>> should be an issue; can you elaborate?
>
> Keith, the system(s) we have to work with are connected to disks in a
> way that seriously affects performance. I've seen a file copy last a
> little over one minute, with a filesize of approx. 2 MB. A copy may
> also just fail. The function described in the OP may be used for
> several files, say about 20 and all at least 1 MB in size. That is
> certainly tot impressive by todays standards and shouldn't be a
> challenge for the underlying hardware. Unfortunately, these things do
> fail occasionally and when a copy fails then system() does not signal
> that failure. I'd rather know about it and hence the desire to
> perform the copy in my own code. Malcolm's example demonstrates the
> various possibilities to signal an error situation.
(Please don't quote signatures.)
If your OS file copying command can fail to copy the file and
not signal that failure, then you've got some serious problems.
I'm skeptical that reimplementing file copying in C will avoid
those problems. You might get better answers in a forum dedicated to
your operating system.
Personally, I probably wouldn't do something like this in C.
I'd probably use Perl, either with system() to invoke "cp", or
using Perl's standard File::Copy module (the latter isn't as prone
to "foo ; rm -rf ~ ; bar.pdf" attacks). Whether you use Perl or not,
this looks like a job for a scripting language.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 01:03 -0800
Re: copying files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-02-16 01:23 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 01:31 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 03:14 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 09:43 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 14:59 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 15:06 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 03:13 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 09:56 -0800
Re: copying files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-02-16 10:11 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 15:11 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 15:21 -0800
Re: copying files Philip Lantz <prl@canterey.us> - 2012-02-17 09:53 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-18 07:22 -0800
Re: copying files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-02-17 03:36 -0800
Re: copying files Willem <willem@toad.stack.nl> - 2012-02-17 22:04 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-18 07:28 -0800
Re: copying files Willem <willem@toad.stack.nl> - 2012-02-18 21:28 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-18 07:19 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 15:02 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 01:34 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 03:27 -0800
Re: copying files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-16 17:11 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 14:57 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 09:54 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 06:41 -0800
Re: copying files JohnF <john@please.see.sig.for.email.com> - 2012-02-16 09:49 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 03:10 -0800
Re: copying files JohnF <john@please.see.sig.for.email.com> - 2012-02-16 11:52 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 06:56 -0800
Re: copying files David Thompson <dave.thompson2@verizon.net> - 2012-02-24 04:43 -0500
Re: copying files Ike Naar <ike@iceland.freeshell.org> - 2012-02-16 16:19 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 14:50 -0800
Re: copying files David Thompson <dave.thompson2@verizon.net> - 2012-02-24 04:43 -0500
Re: copying files Nobody <nobody@nowhere.com> - 2012-02-16 10:58 +0000
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 09:41 -0800
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 14:59 -0800
Re: copying files Nobody <nobody@nowhere.com> - 2012-02-17 06:25 +0000
Re: copying files Kleuske <kleuske@nowhere.net> - 2012-02-16 11:15 +0000
Re: copying files Hans Vlems <hvlems@freenet.de> - 2012-02-16 06:45 -0800
Re: copying files Keith Thompson <kst-u@mib.org> - 2012-02-16 09:49 -0800
csiph-web