Results 1 to 8 of 8

Thread: Bundled files

  1. #1

    Bundled files

    is it possible to extract the bones.jpg and bones_all.x to the place the program.exe extract itself ? because the bundled thinbasic code exe does not left any trace of the remnants of its bundled exe even if we view the hiden files in the code.exe folder..
    before many years i want to post a program which have pictures and i don't want the users to change those pictures but don't have any clue how to do that except using commercial programs which bundle everything (code and pictures) in one exe. so i have abandoned the project. but your new Lib Eros seems have this ability. i saw many people request this feature in the web but i don't see any solutions.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hi Primo,

    I removed you post from the other thread because it merits to be into a specific dedicated thread.
    I will reply in few minutes about latest thinBundle functionalities we recently added in thinBasic 1.9.16.16

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Latest thinBasic 1.9.16.16 has new features regarding bundling files.
    You can specify what files to bundle inside bundled executable and where to extract at runtime.

    Se more info at http://www.thinbasic.com/public/prod...thinbundle.htm
    And more specific bundling file info at http://www.thinbasic.com/public/prod...undle_file.htm
    As you can see, you have many options on how to include and how to extract those bundled file.
    If you do not specify where to extract attached files, they will be extracted into what we call IsolationPath, a temporary directory created on the fly into user temp area used to extract all needed modules and files bundled into the executable. Isolation path will have the name of a GUID and will be always different and unique at every bundled executable execution.

    You can get info about this directory at runtime using new APP_... functions:


    Attached thinBundle pictures where will be listed your bundled files recognized from your script.

    Let me know if the above explanations are enough for what you need or you need some more info.

    Ciao
    Eros
    Attached Images Attached Images
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    A little side note: I'm not aware of anyone still using those bundling functionalities other than me at work.
    So you would be the first

    Keep me informed if it is working fine or you need some additional functionality. I will be happy to discuss and possibly to add new features.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    Thank you Eros, i have tried the program GDIp_LoadImage.tbasic from the thinbasic examples with the images.zip with password asd the images is inside images folder. but don't know how to extract all the images pictures and not the images one by one
    sBuffer = ZLib_ExtractToString(ZIPFileName, "images\bones.jpg", "asd")
    Save_File(APP_ScriptPath & "images\bones.jpg", sBuffer)
    i want to display the images without the others catch it to modify it

    wrong code:
    '------------------------------------------------------------------------------
    ' Load needed modules
    '------------------------------------------------------------------------------
    Uses "UI", "File", "GdiP"
    Uses "ZLib"
    #BUNDLE File ""   , "images.zip", "images.zip"      , FileIsMandatory=0, ReplaceExisting=1, DeleteOnClose=1 
    Dim sBuffer     As String
    Dim ZIPFileName As String        
     
    ZIPFileName = APP_ScriptPath & "images.ZIP"
     
    sBuffer = ZLib_ExtractToString(ZIPFileName, "images\bones.jpg", "asd")
    Save_File(APP_ScriptPath & "images\bones.jpg", sBuffer)
     
    
    '---Test if module was loaded. If not, abort!
    'if uses("GDIP") < 0 then
    '  msgbox 0, "GDI+ lib not found"
    '  stop
    'end if
    
    dim wWidth      as long value 425
    dim wHeight     as long value 425  
    
    function TBMain()
    
      '------------------------------------------------------------------------------
      ' Create dialog
      '------------------------------------------------------------------------------
      dim hDlg as dword
      DIALOG NEW pixels, 0, "thinBasic using GDI+", -1, -1, wWidth, wHeight, _
                            %WS_DLGFRAME          OR _
                            %DS_CENTER            OR _
                            %WS_CAPTION           OR _
                            %WS_SYSMENU           OR _
                            0 TO hDlg
    
      '------------------------------------------------------------------------------
      ' Show dialog
      '------------------------------------------------------------------------------
      DIALOG SHOW modal hDlg, call dlgCallback
    
    end function
    
    callback function dlgCallback() as long
      Dim ImagesDir   As String = APP_SourcePath  + "Images\"
      'dim JPGFileName as string = App_SourcePath + "Images\ferrari-enzo.png"
      dim lWidth      as long
      dim lHeight     as long
      dim nFiles      as long
      dim sFiles()    as string
      dim Counter     as long
      dim x           as long
      dim y           as long
      dim cWidth      as long
      dim cHeight     as long
      dim cForLine    as long
      
      dim hBitmap, hGpBitmap, pThumbnail AS long
      
      select case cbMsg
        
        case %WM_INITDIALOG
          '------------------------------------------------------------------------------
          ' Create controls and Load images
          '------------------------------------------------------------------------------
          nFiles = DIR_ListArray(sFiles, ImagesDir, "*.jpg", %FILE_NORMAL Or %FILE_ADDPATH)
          
          x = 5
          y = 5
          cForLine  = 4
          cWidth    = (wWidth - (x * (cForLine + 2)) ) / cForLine
          cHeight   = cWidth
    
          for Counter = 1 to nFiles
            
            Control Add Label, CBHNDL, 1000 + Counter, "", x, y, cWidth, cHeight, %SS_SUNKEN Or %SS_BITMAP
    
            '---Create an image handle
              hGpBitmap = GDIp_CreateBitMapFromFile(sFiles(Counter))
            '---Get image W and H
            '  lWidth  = GDIP_GetImageWidth(hGpBitmap)
            '  lHeight = GDIP_GetImageHeight(hGpBitmap)
            '---Alternative way to get width and height directly from file:
            '  GDIp_GetImageSizeFromFile(JPGFileName, lWidth, lHeight)
    
              pThumbnail = GDIp_GetImageThumbnail(hGpBitmap, cWidth, cHeight) 
    
    
            '---Convert to a hBitbam handle
              hBitmap = GDIp_CreateHBitMapFromBitmap(pThumbnail, 0)
    
    'MsgBox 0, sFiles(Counter) & Str$(hGpBitmap) & Str$(pThumbnail) & Str$(hBitmap)
            '---Release GDI image
              GDIp_DisposeImage(hGpBitmap)
              GDIp_DisposeImage(pThumbnail)
    
            '---Converto to other formats
            'GDIp_ConvertImage(sFiles(Counter), sFiles(Counter) & ".BMP", "image/bmp")
            'GDIp_ConvertImage(sFiles(Counter), sFiles(Counter) & ".JPG", "image/jpeg")
            'GDIp_ConvertImage(sFiles(Counter), sFiles(Counter) & ".TIFF", "image/tiff")
            'GDIp_ConvertImage(sFiles(Counter), sFiles(Counter) & ".gif", "image/gif")
    
            CONTROL SEND        cbHndl, 1000 + Counter, %STM_SETIMAGE, %IMAGE_BITMAP, hBitmap 
    
            '---Release temp hBitmap
            'object_delete(hBitmap)
            'control set resize  hDlg, 1000 + Counter, 0, 1, 0, 0
            
            x += 5 + cWidth
            if mod(Counter, cForLine) = 0 then
              x = 5
              y += 5 + cHeight
            end if
            
          next
          
      end select
    
    end function
    
    http://wikisend.com/download/576776/images.zip

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hi primo,

    there are several problems I need to solve in order to give you a full working example:
    • ZLib_ExtractToString does not work with Zip files having subdirectory inside. I need to fix this (easy)
    • #BUNDLE File ... I need to add an option to extract files into IsolationPath. Actually always execution path is used and this will be visible (easy)
    • GDI Plus: I'm pretty sure I can add some functions working with buffer instead of having to store images files into the disk (I have to better study GDI+ and see what I can do)



    Anyway an example to list and save files on disk from Zip can be something like the following but first ZLib_ExtractToString must be fixed unless you replace "\" with"/" before passing file name to ZLib_ExtractToString.
    Give me few days (max during the week-end) and I will fix all and possibly simplify a lot.

    Eros

    String ExePath                '---Will contain execution path
    Dim sBuffer As String
    Dim ZIPFileName As String
    
    
    '---Determine Execution path checking if script is bundled or not
      If APP_IsIsolated Then
        ExePath = APP_IsolationPath
      Else
        ExePath = APP_SourcePath
      End If
      PrintL "Exe path:", ExePath
    
    
    '---Now we have the name of the ZIP
      ZIPFileName = ExePath & "images.ZIP"
      PrintL "Zip name:", ZIPFileName
    
    
    '---List files inside zip file. Files will contain full path inside zip
      sBuffer = ZLib_List(ZIPFileName)
    
    
    '---Load a matrix of file names and file info. See ZLib_List help
      String sFiles()
      Long nFiles
      nFiles = Parse sBuffer, sFiles, $CRLF, $TAB
      PrintL "Number of files in ZIP:", nFiles
      
    '---Make directory if it does not exists
      DIR_MakeAll(ExePath & "\images")
      
    '---Extract all files from ZIP and save to disk
      String sFileNameInZip
      String sFileNameOnly
      Long Counter
      For Counter = 1 To nFiles
        sFileNameInZip = sFiles(Counter, 1)
        sFileNameOnly = Remain$(sFileNameInZip, "\")
        sBuffer = ZLib_ExtractToString(ZIPFileName, sFileNameInZip, "asd")
    
        '---Save file
        Save_File(ExePath & "images\" & sFileNameOnly, sBuffer)
    
        PrintL "File saved", ExePath & sFileName
      Next
    
    Last edited by ErosOlmi; 10-03-2016 at 00:10.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    Hi Eros
    i thought now that there is no point we add passworded images.zip to the bundled code exe. because images.zip itself is passworded, so there is no point to include it inside the exe.
    so no need to put effort about this topic, since myself was ambiguous about the idea of bundling. but instead of that yes to simplify the bundling: such as including the files such as pictures from the IDE of bundling with a button like browse instead of writing in the code #BUNDLE File

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    OK, so give me few days and I will fix zLib regarding sub directory problem and I will release a new thinBasic version.
    I have few ideas on how to automatically extract all zipped files into a string array and few others massive functionalities.

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. Console not the same when bundled
    By EmbeddedMan in forum Console
    Replies: 7
    Last Post: 07-09-2016, 22:40
  2. Help me: test this bundled Exe
    By ErosOlmi in forum thinBasic vaporware
    Replies: 4
    Last Post: 09-06-2013, 23:36
  3. Icon changer for bundled thinBasic files
    By GSAC3 in forum thinBundle
    Replies: 15
    Last Post: 31-01-2010, 19:49
  4. DIR_GetCurrent behaves different with a bundled EXE
    By Michael Hartlef in forum File
    Replies: 13
    Last Post: 19-05-2008, 10:36
  5. Bundled exe and command line
    By ErosOlmi in forum thinBundle suggest new features
    Replies: 5
    Last Post: 21-02-2007, 14:04

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •