Platforms to show: All Mac Windows Linux Cross-Platform

/Compression/Old ZipMBS class/zip folder with encryption


Required plugins for this example: MBS Main Plugin, MBS Compression Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Compression/Old ZipMBS class/zip folder with encryption

This example is the version from Sun, 31th Oct 2015.

Project "zip folder with encryption.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
EventHandler Sub Open() const password = "Hello" dim f as FolderItem = Createfiles dim s as FolderItem = SpecialFolder.Desktop.Child("test.zip") dim z as new ZipMBS(s,0) ZipFolder password, z,f,"" z.Close("global comment") End EventHandler
Function CreateFiles() As FolderItem dim folder as FolderItem folder=SpecialFolder.Desktop.Child("ziptest") folder.CreateAsFolder dim subfolder as FolderItem = folder.Child("test folder") subfolder.CreateAsFolder dim subsubfolder as FolderItem = subfolder.Child("test subfolder") subsubfolder.CreateAsFolder dim p as Picture= LogoMBS(500) dim file as FolderItem file = folder.Child("logo in folder.jpg") file.SaveAsJPEG p file = subfolder.Child("logo in subfolder.jpg") file.SaveAsJPEG p file = subsubfolder.Child("logo in subsubfolder.jpg") file.SaveAsJPEG p Return folder End Function
Sub ZipFile(password as string, z as ZipMBS, f as FolderItem, path as string) const WindowBits = 15 const memLevel = 8 dim d as date dim b as BinaryStream dim info as ZipFileInfoMBS b=f.OpenAsBinaryFile(false) if b = nil then Break // failed to open? Ignore? return end if info=new ZipFileInfoMBS info.SetDate f.ModificationDate info.ExternalFileAttributes=0 info.InternalFileAttributes=0 info.DosDate=0 dim data as string = b.Read(b.Length) dim crc as integer = CRC32StringMBS(0, data) z.CreateFile path+f.name, info, "", "", "", z.MethodDeflated, z.CompressionBestCompression, false, false, WindowBits, memLevel, z.StrategyDefault, password, crc z.Write data z.CloseFile End Sub
Sub ZipFolder(password as string, z as ZipMBS, source as FolderItem, path as string) dim f as FolderItem dim i,c as integer path=path+source.Name+"/" c=source.Count for i=1 to c f=source.TrueItem(i) if f=nil then 'ignore elseif f.Directory then ZipFolder password, z, f, path else ZipFile password, z, f, path end if next End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Compression Plugin.


The biggest plugin in space...