Jump to content











Photo
- - - - -

Script attachements

attachment script zip

  • Please log in to reply
5 replies to this topic

#1 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12688 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 01 June 2012 - 12:26 PM

History
Since very early beginning WinBuilder offers the possibility to attach files directly to the script.
Because the files can be also binaries like *.exe, and a script should be openable by any text editor w/o destroying the binary contents, the attachements are coded in base64.
To avoid misunderstandings: Before encoding the files internally are zipped to save space.

Disadvantages
Let me start with an example from reality:
multiPE contains the classic script "CD-Opera" by Medevil. The script has neary 4 MB attachements, which are unchanged since long time.
But during project development, the script code sometimes changes.
On every change of only one script line 4 MB have to be uploaded and downloaded by the user.

First solution step
There exists a project (multiPE folder) mirror (multiPE_Enc folder) which contains all the attachments. multiPE contains the script code only.
An intelligent "Extract" handling decides whether to extract from script or from mirror script.
This has been realized in multiPE version 28

Second solution step
When the files are split to a mirror, they not have to be base64 encoded. When they are zipped binaries, they are remarkably smaller.
The mirror now has the name "multiPE_Zip"
I realized that in multiPE version 39.

Tests
The "classic" encoded files brought a multiPE size of about 45 MB
Step 1 brought a multiPE size of about 6 MB and a multiPE_Enc size of about 39 MB
Step 2 brought the same multiPE size and a multiPE_Zip size of about 27 MB
For all three alternities the build time of the XP track has been the same of about 3 minutes.

Certification
Processing with the SplitBinEx application of course changes some files and makes the certification of that files invalid.
When before processing, the file have had a valid certification, the certification is renewed by SplitBinEx.

Theory
The intelligent decide mechanism:

[Build-Binary]

Set,#4,False

If,#2,EQUAL,InterfaceEncoded,Set,#3,#1

Else,Begin

  If,Not,EXISTVAR,%exe%,Begin

	Set,%exe%,SplitBinEx.exe

	If,Not,EXISTFILE,%Tools%%exe%,ExtractFile,%SplitBinScript%,Folder,%exe%,%Tools%

  End

  System,ERROROFF

  IniRead,#1,Main,HasBinary,%_BinFile%

  If,%_BinFile%,EQUAL,,Set,%_BinFile%,#1

  Else,Begin

	StrFormat,EXT,%_BinFile%,%_ext%

	If,%_ext%,EQUAL,.zip,Begin

	  Set,%_BinDir%,%ProjectDir%_Zip

	  Set,#4,True

	End

	Else,Set,%_BinDir%,%ProjectDir%_Enc

	Set,%_BinFile%,%_BinDir%%_BinFile%,GLOBAL

  End

  Set,#3,%_BinFile%

End

Modified "Extract" example:

[ExtractFile_Ex]

Run,%SplitBinScript%,Build-Binary,#1,#2,OUT:%_BinFile%,OUT:%_IsZip%

If,%_isZip%,EQUAL,False,ExtractFile,%_BinFile%,#2,#3,#4

Else,ShellExecute,Hide,%Tools%7z.exe,"e -y #$q-o#4#$q #$q%_BinFile%#2.7z#$q #3"



Peter

Edited by pscEx, 04 June 2012 - 04:04 PM.
Added "Certification". Changed code following actualized version


#2 sbaeder

sbaeder

    Gold Member

  • .script developer
  • 1336 posts
  • Location:usa - massachusettes
  •  
    United States

Posted 01 June 2012 - 09:19 PM

good to see some performance/size testing and movement on an issue discussed elsewhere... But to make this more universal,would the next step be to formalize this more? Maybe propose some sort of an API or "standard" to the current process for handling files that we can promote for just this sort of thing? Let me know how I can help.

:cheers:
Scott
  • Nuno Brito likes this

#3 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12688 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 04 June 2012 - 04:40 PM

I changed the SplitBinEx.script in the multiPE project.

The script can now used in any project using the %API%.

Installation is done by one click on the "Install" button.

After installation the user has only to use "ExtractFileEx" replacing "ExtractFile". Same for the other attachment functions.

But I have no idea, how to "promote".

Peter

#4 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12688 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 04 June 2012 - 04:41 PM

I changed the SplitBinEx.script in the multiPE project.

The script can now be used in any project using the %API%.

Installation is done by one click on the "Install" button.

After installation the user has only to use "ExtractFileEx" replacing "ExtractFile". Same for the other attachment functions.

But I have no idea, how to "promote".

Peter

#5 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12688 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 11 June 2012 - 07:27 AM

I changed the SplitBinEx.script in the multiPE project.
  • SplitBinEx work around a logical bug in "Common"_API, which reads WinBuilder internal undocumented / unpublished data about encoded files hardcoded, rather than to use WinBuilder functions.
In the API there has been
  • IniRead of a key inside the Encoded Folder data of %ScriptFile%
  • If,EXISTSECTION of an Encoded Folder data section of %ScriptFile%
In the new stucture the data are not in %ScriptFile%, but external.

Peter

#6 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12688 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 10 July 2012 - 12:03 PM

I changed the SplitBinEx.script in the multiPE project.
  • Added button to recalculate sizes of all binary attachments.
  • Checkbox for base64 now hidden and unchecked. Therefore 7z compressed attachments are used.
  • Some smaller enhancements and bug fixes.
Peter
  • TheHive likes this





Also tagged with one or more of these keywords: attachment, script, zip

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users