Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incompatible types: PResStringRec and String

Status
Not open for further replies.

RandyBlackburn

Programmer
Oct 1, 2002
153
US
I'm using an old (Delphi I) component in turbo delphi, and I'm getting the error above. The code generating it is below... I got the error on both of the bolded lines.

I don't understand what's wrong. Are there components that perform these file copy/move functions in turbo delphi or somewhere else?

Any help will be appreciated

Randy

Code:
procedure CopyFile(const FileName, DestName: TFileName);
var
  CopyBuffer: Pointer; { buffer for copying }
  TimeStamp, BytesCopied: Longint;
  Source, Dest, SFOpenError, SFCreateError: Integer; { handles }
  Destination: TFileName; { holder for expanded destination name }
const
  ChunkSize: Longint = 8192; { copy in 8K chunks }
begin
  Destination := ExpandFileName(DestName); { expand the destination path }
  {if HasAttr(Destination, faDirectory) then { if destination is a directory... }
    {Destination := Destination + '\' + ExtractFileName(FileName);}{ ...clone file name }
  TimeStamp := FileAge(FileName); { get source's time stamp }
  GetMem(CopyBuffer, ChunkSize); { allocate the buffer }
  try
    Source := FileOpen(FileName, fmShareDenyNone{Write}); { open source file }
    [b]if Source < 0 then raise EFOpenError.Create(FmtLoadStr(SFOpenError, [FileName]));[/b]
    try
      Dest := FileCreate(Destination); { create output file; overwrite existing }

     [b] if Dest < 0 then raise EFCreateError.Create(FmtLoadStr(SFCreateError, [Destination]));[/b]
      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 }
{        SetFileTimeStamp(Destination, TimeStamp);} { clone source's time stamp }{!!!}
      end;
    finally
      FileClose(Source); { close the source file }
    end;
  finally
    FreeMem(CopyBuffer, ChunkSize); { free the buffer }
  end;
end;
 
CopyFile is included in Windows API. no need for own routines :

here's the full description:

sample:
Code:
Uses Windows,..
...
procedure CopyFileWithOverwrite(Source, Dest : String);
begin
 CopyFile(PChar(Source), PChar(Dest), False);
end;

Cheers,
Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top