Jump to content

Recommended Posts

Posted (edited)

This is a small UDF I put together just for fun that will embed and extract complete directory's in and from your script. It only has two functions, _EmbeddedDirectory_Create() and _EmbeddedDirectory_Extract(). The udf uses Wards machine code functions so they have pretty good speed. The example I set up packs all files located in Autoit Include directory. Both compression and decompression of the directory was less than 500ms on my pc which I was happy with. Let me if you have any problems or questions. Thanks

 

Example:

 

#include "EmbedDir.au3"

;Check location of autoit includes
Global $sIncludeDir = 'C:\Program Files\AutoIt3\Include\'
If Not FileExists($sIncludeDir) Then $sIncludeDir = 'C:\Program Files (x86)\AutoIt3\Include\'
If Not FileExists($sIncludeDir) Then Exit (MsgBox(0, 'Directory Not Found', 'Unable to locate Includes Directory'))

;Create embedded directory function
Global $sCompressed_Includes = _EmbeddedDirectory_Create($sIncludeDir, '_Extract_Includes')
Global $iTime = (@extended / 1000) & ' ms'

;create example file and write extract function to it
Global $hExtractExample = FileOpen(@ScriptDir & 'Extract_Example.au3', 2)
FileWrite($hExtractExample, '#include "EmbedDir.au3"' & @LF & @LF & _
  '$sExt = _Extract_Includes()' & @LF & _
  '_EmbeddedDirectory_Extract($sExt, @ScriptDir & "AutoIt_Extracted")' & @LF & _
  'ConsoleWrite("Extract Time = " & @extended/1000 & "ms" & @LF)' & @LF & @LF & _
  $sCompressed_Includes)
FileClose($hExtractExample)

;Show stats of the directory we just embeded
$aSize = DirGetSize($sIncludeDir,1)
If IsArray($aSize) Then
    Msgbox(0,"Directory Details", _
  "Size = " & Int($aSize[0]/1024) & 'KB' & @LF & _
        "Files = " & $aSize[1] & @LF & _
  "Dirs = " & $aSize[2] & @LF & _
  "Compression time = " & $iTime & @LF & @LF & _
  "Open Extract_Example.au3 to extract")
EndIf

 

UDF:

EmbedDir.zip

Edited by Beege
  • 5 months later...
  • 3 years later...
Posted
  On 12/26/2011 at 4:06 PM, Beege said:
Expand  

@Beege this link is broken, can you post it again ?

mLipok

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 6/1/2016 at 11:38 PM, mLipok said:

@Beege this link is broken, can you post it again ?

mLipok

Expand  

Thanks for pointing that out mLipok. The original zip is attached now

Posted

Nice UDF and Example.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 11 months later...
Posted

Hey quick question if you don't mind..  Does a second script have to be generated to obtain the directory that was embedded in the initial script?  Can it all be done from within one single script?  Thanks in advance.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...