Hi,
Don't know if it is cross platform, but I use this under windows :
function CopyFile(FileName,DestName:string):Boolean;
var
CopyBuffer: Pointer; // buffer for copying
BytesCopied: Longint;
Source, Dest: Integer; // handles
Destination: TFileName; // holder for expanded destination name
const
ChunkSize: Longint = 8192; // copy in 8K chunks
begin
Result:=True;
GetMem(CopyBuffer, ChunkSize); // allocate the buffer
try
Source := FileOpen(FileName, fmShareDenyWrite); // open source file
if Source < 0 then begin Result:=False; Exit; end;
try
Dest := FileCreate(DestName); // create output file; overwrite existing
if Dest < 0 then begin Result:=False; Exit; end;
try
repeat
BytesCopied := FileRead(Source, CopyBuffer^, ChunkSize); //
read chunk
if BytesCopied > 0 then // if we read anything...
FileWrite(Dest, CopyBuffer^, BytesCopied); // ...write chunk
until BytesCopied < ChunkSize; // until we run out of chunks
finally
FileClose(Dest); // close the destination file
end;
finally
FileClose(Source); // close the source file
end;
finally
FreeMem(CopyBuffer, ChunkSize); // free the buffer
end;
end;
It is from an old unit I used with Delphi
Philippe
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives