Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Porting issue from D6 to Delphi Seattle 2010


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Feb 2, 2016 5:11 PM Last Post By: Paul Lynch
Paul Lynch

Posts: 4
Registered: 2/16/16
Porting issue from D6 to Delphi Seattle 2010  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 2, 2016 2:54 PM
Having the joys of porting an old D6 project to something bit more "newer"
here my error which i know is posted all over the internet with hints etc

E2010 Incompatible types: 'string' and 'TMemoryStream'

Here is the code block

procedure RLLoadResource(const archiveName, resourcePath:string; stream:TStream);
   var
      needClose: boolean;
      idx: integer;
      rlType: TRLResourceType;
      mStream: TMemoryStream;
   begin
   if (not Assigned(RLArchiver)) or (RLArchiver.FileName<>archiveName) or (not RLArchiver.IsOpen) then
      begin
      RLOpenArchive(archiveName);
      needClose:=true;
      end
   else
      needClose:=false;
   mStream:=TMemoryStream.Create;
   try
      with RLArchiver do
         begin
         idx:=IndexOfFile(UpperCase(resourcePath));
         if idx<>-1 then
            begin
            with Files[idx].FileEntry do
           ExtractFileToStream(Segment,Offset,ArchiveInfo.CompressedSize,mStream);
            end
         else
            raise EResourceNotInArchive.Create('Resource '''+resourcePath+''' is not in archive '''+archiveName+'''!');
         end;
      //
      mStream.Seek(0,0);
      mStream.Read(rlType,sizeof(rlType));
      if Assigned(RLLoaders[ord(rlType)]) then
         RLLoaders[ord(rlType)](mStream,stream)
      else
         raise EResourceNoLoaderProc.Create('Resource '''+resourcePath+''' in archive '''+archiveName+''' has no loader procedure!');
   finally
      mStream.Free;
   end; // try
   if needClose then
      RLCloseArchive;
   end;


Line in question brings up error
ExtractFileToStream(Segment,Offset,ArchiveInfo.CompressedSize,mStream);
 


Here is the function its calling,
procedure TCustomExtractor.ExtractFileToStream( aSegment : Word; anOffset, compressedSize : Integer; destStream : TStream );
begin
  if not CheckBusy then
    DoExtractFileToStream( aSegment, anOffset, compressedSize, destStream );
end;


And this is the part that calls first section

procedure TResourceModule.LoadResource(const resourcePath:string; stream:TStream);
   begin
   if FArchiveName<>'' then
      begin
      stream.Seek(0,0);
      RLLoadResource(FArchiveName,resourcePath,stream);
      stream.Seek(0,0);
      end;
   end;


The strings are start filename, location
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Porting issue from D6 to Delphi Seattle 2010  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 2, 2016 3:52 PM   in response to: Paul Lynch in response to: Paul Lynch
Paul wrote:

E2010 Incompatible types: 'string' and 'TMemoryStream'

I see nothing in this code, and especially not in the line you pointed out,
that is trying to assign a String to a TMemoryStream or vice versa. The
ONLY way I could see that error happening is if either:

1. Files[idx].FileEntry has its own mStream member that is a String. Since
the call to ExtractFileToStream() is inside a 'with' statement, any conflicting
members of FileEntry will have priority over any local variables that have
the same names.

2. the code is calling some other version of ExtractFileToStream() than the
one you are expecting.

On a side note, RLCloseArchive() should probably be inside a try/finally
block of its own.

--
Remy Lebeau (TeamB)
Paul Lynch

Posts: 4
Registered: 2/16/16
Re: Porting issue from D6 to Delphi Seattle 2010  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 2, 2016 5:04 PM   in response to: Paul Lynch in response to: Paul Lynch
Interesting reply, I went through the
idx:=IndexOfFile(UpperCase(resourcePath));


and this is what we find

function TArchiverRoot.IndexOfFile( const FileName : String ) : Integer;
var
  i : Integer;
begin
  Result := -1;
  for i := 0 to FileCount - 1 do
    with Files[i] do
      if CompareStr( FileEntry.Name, FileName ) = 0 then
        begin
          Result := i;
          Break;
        end;
end;
 


This is last point it uses string
Paul Lynch

Posts: 4
Registered: 2/16/16
Re: Porting issue from D6 to Delphi Seattle 2010  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 2, 2016 5:11 PM   in response to: Paul Lynch in response to: Paul Lynch
Point 2 was correct answer I had a copy of a previous version in
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02