CopyFileA vs OS-COMMAND

Chris Kelleher

Administrator
Staff member
Hi Peggers,

I'm trying to duplicate the following OS call:

copy file1 >> file2


I've looked at CopyFileA, but the only mode it seems to have is overwrite /
don't overwrite.
I'm trying to avoid Progress's os-command, because I'm assuming (yikes !)
that a direct API call would be faster.


What API call should I use to merge multiple files into one file ?

Regards,

Rich


Richard Herring
Programming Services

Bac-Tech Systems, Inc.
http://www.bac-tech.com/ <http://www.bac-tech.com/>
 

Chris Kelleher

Administrator
Staff member
Hi,

> What API call should I use to merge multiple files into one file ?

I think you will have to code it on your own - best is in a DLL, when you're
hunting for speed.

> I'm trying to avoid Progress's os-command, because I'm assuming (yikes !)
> that a direct API call would be faster.

I was interested, how big the difference is, and used the following
test-prog:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
def var i as int.
def var r as int.
def var e1 as int.
def var e2 as int.

e1 = etime(yes).
do i = 1 to 10:
os-copy ".\dfue.ass" value(".\dfue1" + string(i, "99") + ".ass").
end.
e1 = etime(no).

e2 = etime(yes).
do i = 1 to 10:
run CopyFileA ( ".\DFUE.ass",
".\DFUE2" + string(i, "99") + ".ass",
0,
output r).
end.
e2 = etime(no).

message "e1 =" e1 skip
"e2 =" e2 skip
"RetVal = " r
view-as alert-box.


procedure CopyFileA external "Kernel32":
def input parameter lpFileFrom as char .
def input parameter lpFileTo as char .
def input parameter bFailIfExists as long .
def return parameter RetVal as long .
end.

[/code]

My results:

Small input-file (674 Bytes):
No TargetFile existes: e1 = 80, e2 = 31
TargetFile existes: e1 = 50, e2 = 30

Large input-file (3.7 MB):
No TargetFile existes: e1 = 13039, e2 = 8072
TargetFile existes: e1 = 11416, e2 = 9254


As a result, for me, API-ing in this case isn't that worth, because it is
only two times faster (approx.).

bye

Michael Rüsweg-Gilbert
mrz Kaufring AG
Düsseldorf
Germany
rg@kaufring.de
 

Chris Kelleher

Administrator
Staff member
> I'm trying to duplicate the following OS call:
>
> copy file1 >> file2

How about OS-APPEND?

> I've looked at CopyFileA, but the only mode it seems to have is overwrite /
> don't overwrite.
> I'm trying to avoid Progress's os-command, because I'm assuming (yikes !)
> that a direct API call would be faster.

That hardly seems like a worthwhile area to focus on for speed. Why would
you want to bind yourself to a specific OS, and worse the API thereof,
over copying files?

> What API call should I use to merge multiple files into one file ?

I wouldn't. It's a 4gl, if you're going to go to this sort of low level
stuff for this purpose you're almost certainly using the wrong language.

-----------------------------------------------------------------------------
| Tom Bascom You can't make a diamond by patting a lump
| tom@lkw.com of coal on the head and saying "nice job"
| tom.bascom@eds.com
 

Chris Kelleher

Administrator
Staff member
Tom Bascom wrote:

> > What API call should I use to merge multiple files into one file ?
>
> I wouldn't. It's a 4gl, if you're going to go to this sort of low level
> stuff for this purpose you're almost certainly using the wrong language.

Hi Tom,

I am pleasantly surprised you are reading this list :) I agree I would not
use API calls for this particular problem, but I would be using lots of
API calls anywhere if I would trust that this 4gl would support them
efficiently. After all, we are hired to make Windows applications in
Progress, not for authoring 4gl source. What is so great about 4gl anyway?


---------------
Search-engine for Progress related websites:
http://home.wxs.nl/~jurjen.dijkstra/prodevring/ringsearch.html

Windows API examples for Progress 4GL:
http://home.wxs.nl/~jurjen.dijkstra/api/index.html
 
Top