🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16420

Re: File Copy Operation

#16420
From: Ed Mulroy [TeamB]
Date: Thu, 15 May 2003 16:42
46 lines
3332 bytes
If you are reading, examining and possibly altering the file's data prior to
writing a new file then what you are doing is not a copy and a comparison to
the speed to that of Windows' CopyFile operation is not valid.

If I had that task and were concerned about speed, I would apportion most of
my efforts to two items:

-I would use the native API for the file operations
-I would try to optimize my activities with respect
 to data examination and alteration.

I would probably use CreateFile, ReadFile, WriteFile and CloseHandle and
specificly open with FILE_FLAG_NO_BUFFERING and allocate aligned data
buffers to facilitate that mode.

I would probably use one of several different functions for examining and
altering a given file and its data depending upon which variation of
alteration is desired for a given file and what file size is to be handled.

If many files were to be handled, it may be profitable to investigate
apportioning the files among various threads and investigate the utility of
requesting a higher priority from Windows.

Note that without careful programming, no changes, including none of what I
have said, are likely to provide significant benefit.  You must try code,
evaluate its performance and compare to alternate versions of the code.
Typically you will find that the bulk of any differences in speed reside in
20% or less (probably much less) of the code but without evaluation and
performance comparisons you will end up spending time to optimize portions
where the effects of the optimization are trivial.  For instance, it could
turn out that performance using TFileStream is within 2% of that using
other, lower level methods, because the bulk of the time is spent elsewhere.

.  Ed

> Muhammad Momin Rashid wrote in message
> news:3ec3be2e@newsgroups.borland.com...
>
> I am not using CopyFile function because I need to have
> control over the data being copied, in some cases I need
> to clean the corrupted data (which occurs due to faulty
> media).  This the reason I am reading file in chunks
> and writing these chunks to a new file.
>
> Given the above scenario, can you think of an alternate i can
> use, which is both speedier and gives me this sort of control?
Technical Details
Message-ID: <3ec3c37a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ec35dd4@newsgroups.borland.com> <3ec3944e$1@newsgroups.borland.com> <3ec3be2e@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2c3eb0c8d9515a68
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-15 09:47:21 PST
From: "Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ec35dd4@newsgroups.borland.com> <3ec3944e$1@newsgroups.borland.com> <3ec3be2e@newsgroups.borland.com>
Subject: Re: File Copy Operation
Date: Thu, 15 May 2003 12:42:12 -0400
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 24.74.175.102
Message-ID: <3ec3c37a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1053016954 24.74.175.102 (15 May 2003 09:42:34 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail