1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-01-31 07:10:28 -05:00

Fixed unwanted Segfault + small update in UntarEx

This commit is contained in:
Raymond 2010-05-10 14:39:49 +02:00
parent 9c76c1a191
commit b7ac0e8dec
2 changed files with 17 additions and 5 deletions

View File

@ -106,7 +106,9 @@ end;
function UnTar(const Input: TStream; const outputdir: string; overwrite: boolean): boolean; overload;
var
Tar : TTarArchive;
Succ : boolean;
DirRec : TTarDirRec;
FS : TFileStream;
begin;
result := false;
if not DirectoryExists(outputdir) then
@ -114,23 +116,33 @@ begin;
exit;
Tar := TTarArchive.Create(input);
Tar.reset;
Succ := True;
while Tar.FindNext(DirRec) do
begin
if (DirRec.FileType = ftDirectory) then
begin;
if not DirectoryExists(outputdir + DirRec.Name) and not CreateDir(outputdir + DirRec.Name) then
exit
begin
Succ := false;
break;
end;
end else if (DirRec.FileType = ftNormal) then
begin;
if FileExists(outputdir + dirrec.name) and not overwrite then
continue;
Tar.ReadFile(outputdir + dirrec.name);
try
FS := TFileStream.Create(outputdir +dirrec.name,fmCreate);
tar.ReadFile(fs);
FS.Free;
except
Succ := false;
break;
end;
end else
mDebugLn(format('Unknown filetype in archive. %s',[dirrec.name]));
end;
Tar.Free;
Result := true;
Result := Succ;
end;
constructor TProcThread.Create;

View File

@ -134,7 +134,7 @@ begin
for i := l - 1 downto 0 do
begin
if (IncludeBuffer[i].CodeInsight.FileName = FileName) then
if (IncludeBuffer[i].CodeInsight <> nil) and (IncludeBuffer[i].CodeInsight.FileName = FileName) then
begin
DefineMatch := (IncludeBuffer[i].DefinesIn.Defines = Defines.Defines) and (IncludeBuffer[i].DefinesIn.Stack = Defines.Stack);