Results 1 to 5 of 5

Thread: ZIP files

  1. #1

    Exclamation ZIP files

    Hey, there again

    I am wondering if its possible to ZIP files (Create an archive file which is smaller in size and compressed) I assume it would be a function that would require saving in binary...

    I have looked at ZLIB but that's only used to ZIP string information and not files such as bmp, or JPG.

    Is there a method to do this? From within Thin Basic?

    Thanks you!

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

    Actually thinBasic allows compressing/decompressing of strings buffer using STRZIP$ and STRUNZIP$ functions.
    No native compress/decompress file functions are available.
    To compress the content of a file on disk can be done with something like:
    sCompressedBuffer = STRZIP$(File_Load(<your full path file name>))
    
    but this will just create a compressed string buffer of your disk file content.

    Adding new native functionalities letting basic compress/decompress handling of files is not that complex.
    Can you be so kind to describe more what you need to do so I can better understand the direction to go?

    Thanks
    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

    Unhappy :)

    Thanks Eros.

    I want to ZIP the file in the same directory. It will be used to as script that will compare files in the directory based on their date modifided if they are older then X days they will be ziped. ( I have started this i can do this not a problem)

    I have made the following code i dont know if its right so far. But it reads the file i just need to write the part to save it.
    Currently i have:

    Uses "FILE" 
    Uses "ZLIB"
    
    Dim FileName As String = APP_ScriptPath + "myfile.txt" ' Set the file name to use'
    Dim sCompressedBuffer As String  
    Dim sCompressedBuffersave As String 
    Dim FileHandle As DWord
    
    sCompressedBuffer = StrZip$(FILE_Load(FileName)) 
    sCompressedBuffersave = StrZip$(FILE_Save(,"myfile2.txt"))
    
    I was looking at the example of FILE_SAVE but i can't manage to get it to save. Do i need to load the file then open it up then save it? Or would it require FILE_GET, FILE_SEEK,_FILE CLOSE?

    Thank you for your time.

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    The following line is not correct and mainly has no meaning:
    sCompressedBuffersave = StrZip$(FILE_Save(,"myfile2.txt"))
    
    FILE_Save save a string buffer to a file binary or not. It just create a file and put into that file a string buffer up to 2GB of data.

    Consider that compressing a string buffer is not the same as compressing a file into a zip archive even if you load the string buffer from the file.
    I need to develop specific functions that are able to create zip archives, add or extract files to zip archives, ... and so on.

    Now I have more info. I will work on that but nothing for the day after, sorry, I need some time to think what is is the best way to do it.

    In the meantime if you are in hurry you can follow tip indicated by Michael here: http://www.thinbasic.com/community/s...t-in-thinbasic

    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

    Cool Thanks

    Thanks yes, i understand ill have a go with 7ZIP i was thinking of do that. But wans't sure if i could of have used shell command. Thanks for the link ill keep you posted!

Similar Threads

  1. help files
    By newguy1 in forum Shout Box Area
    Replies: 5
    Last Post: 29-03-2006, 11:26

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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