Platforms to show: All Mac Windows Linux Cross-Platform
/Compression/Old ZipMBS class/test huge files with big archive
Required plugins for this example: MBS Util 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/test huge files with big archive
This example is the version from Sun, 17th Mar 2012.
Project "test huge files with big archive.xojo_binary_project"
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
EventHandler Sub Open()
const length = 10000000
// Make a 10 MB big string with random data
ZeroBuffer = RandomBytesStringMBS(length)
System.DebugLog "Start..."
Write
'Read
System.DebugLog "Finished."
quit
End EventHandler
Sub Read()
dim f as FolderItem
dim z as UnZipMBS
dim s as string
dim info as UnZipFileInfoMBS
f=SpecialFolder.Desktop.Child("test.zip")
z=new UnZipMBS(f)
if z.Handle = 0 then
MsgBox "Failed to open zip file."
Return
end if
z.GoToFirstFile
if z.Lasterror <> 0 then
MsgBox "GoToFirstFile: "+str(z.Lasterror)
Return
end if
do
info=z.FileInfo
System.DebugLog "Reading file: "+z.FileName
// filename like test1.txt"
dim size as integer = val(mid(z.FileName,5,1))
z.OpenCurrentFile
if z.Lasterror <> 0 then
MsgBox "GoToFirstFile: "+str(z.Lasterror)
Return
end if
for g as integer = 1 to size
for n as integer = 1 to 100
s = z.ReadCurrentFile(lenb(ZeroBuffer))
if s<>ZeroBuffer then
break
MsgBox "Failed: Data not correct. Buffer read too small."
Return
end if
next
next
System.DebugLog "Read "+Format(z.Position/1000/1000, "0")+" MB"
z.CloseCurrentFile
z.GoToNextFile
loop until z.Lasterror<>0
MsgBox "Everything okay."
End Sub
Sub Write()
dim z as ZipMBS
dim f as FolderItem
dim d as new date
dim info as ZipFileInfoMBS
f=SpecialFolder.Desktop.Child("test.zip")
z=new ZipMBS(f,0)
info=new ZipFileInfoMBS
info.SetDate d
info.ExternalFileAttributes=0
info.InternalFileAttributes=0
info.DosDate=0 // auto
dim size as integer = 3 // 3 GB
System.DebugLog "Write test"+str(size)+".txt with "+str(size)+" GB."
z.CreateFile("test"+str(size)+".txt", info, "", "", "", z.MethodDeflated, z.CompressionBestCompression, true)
// for each GB
for j as integer = 1 to size
// write a little bit more than 1 GB
for k as integer = 1 to 100
z.Write ZeroBuffer
next
next
z.CloseFile
z.Close("global comment")
z = nil
End Sub
Property ZeroBuffer As string
End Class
FileTypes
Filetype text
End FileTypes
End Project
See also:
- /Compression/Old ZipMBS class/CompressFiles test
- /Compression/Old ZipMBS class/unzip
- /Compression/Old ZipMBS class/unzip with encryption
- /Compression/Old ZipMBS class/unzip with folders
- /Compression/Old ZipMBS class/unzip with folders and progressbar
- /Compression/Old ZipMBS class/unzip with offset
- /Compression/Old ZipMBS class/unzip with string
- /Compression/Old ZipMBS class/zip folder
- /Compression/Old ZipMBS class/zip folder with encryption
- /Compression/Old ZipMBS class/zip images
The items on this page are in the following plugins: MBS Compression Plugin.