|
Post by stuart on Dec 15, 2009 11:45:28 GMT -5
I have made a change to MakeNewSFX so that it is (I think) Thread safe, i.e. you can create two different files at the same time.
function TVCLZip.MakeNewSFX(SFXStub: string; FName: string; Options: PChar; OptionsLen: Integer): Integer; { Assumed that FilesList will have files to be included in the newly created SFX } var SFXFile: TLFNFileStream; begin result := 0; if (FName = '') or (SFXStub = '') then exit; if FileExists(FName) and (AnsiCompareText(ExtractFileExt(FName), '.zip') = 0) then SaveNewName := ChangeFileExt(FName, '.exe'); ZipName := FName; if (OptionsLen > 0) then begin SFXFile := TLFNFileStream.CreateFile(SFXStub, fmOpenRead, False, BufferedStreamSize); { Get the Stub } SFXStubFile := TLFNFileStream.CreateFile(TemporaryPath + ExtractFileName(FName), fmCreate, FFlushFilesOnClose, BufferedStreamSize); SFXStubFile.CopyFrom(SFXFile, SFXFile.Size); SFXStubFile.Write(Options^, OptionsLen); SFXFile.Free; SFXStubFile.Seek(0, soBeginning); end else SFXStubFile := TLFNFileStream.CreateFile(SFXStub, fmOpenRead, False, BufferedStreamSize);
try CreatingSFX := True; Result := Zip; if (AnsiCompareText(ExtractFilename(FName), '.zip') = 0) then ChangeFileExt(FName, '.exe'); finally CreatingSFX := False; SFXStubFile.Free; SFXStubFile := nil; SaveNewName := ''; if (OptionsLen > 0) or (Options = nil) then SysUtils.DeleteFile(TemporaryPath + ExtractFileName(FName)); end; end;
Hope this is OK.
Stuart
|
|