// //------------------ DOK FILE -------------------------------------------------- +Header core.util.zip =pkg core.util.zip =title core.util.zip =short *.zip files =desc This library can read or write zip files. It can also convert timestamps from MS-DOS format to regular format, because zip files encode timestamps with the MS-DOS format. // // //------------------ PROTO ----------------------------------------------------- ZipFile +Proto ZipFile =type ZipFile =mode structure =pkg core.util.zip =impl mcy =link =desc This structure describes a file present in a zipped archive. // // //------------------ PROTO ----------------------------------------------------- zipFromFileInfoList +Proto zipFromFileInfoList =type fun list FileInfo -> Str =mode function =pkg core.util.zip =impl mcy =link =desc This function compresses a list of files and returns the binary string ready to be saved as a *.zip file. zipFromFileInfoList (fileListInfo ("tmp/")) // +arg lFileInfo =type list FileInfo =desc A list of files (see bios functions [[fileListInfo]], [[fileInfo]]) // +arg result =type Str =desc A binary string with the zipped archive. // // //------------------ PROTO ----------------------------------------------------- zipFromFileList +Proto zipFromFileList =type fun list [Str Int Str] -> Str =mode function =pkg core.util.zip =impl mcy =link =desc This function compresses a list of files and returns the binary string ready to be saved as a *.zip file. zipFromFileList (["tmp/foo.txt", time(), "Hello Foo"]::["tmp/bar.txt", time()-3600, "Hello Bar"]::nil) // +arg lData =type list [Str Int Str] =desc A list of files to zip. Each tuple is [name timestamp content] // +arg result =type Str =desc A binary string with the zipped archive. // // //------------------ PROTO ----------------------------------------------------- dosTimeFromTime +Proto dosTimeFromTime =type fun Int -> Int =mode function =pkg core.util.zip =impl mcy =link =desc This function returns a MS-DOS timestamp from a regular timestamp. See source code for the description of MS-DOS timestamps. // +arg t =type Int =desc A regular timestamp (a number of seconds since 01/01/1970) // +arg result =type Int =desc A MS-DOS encoded timestamp // // //------------------ PROTO ----------------------------------------------------- dosTimeStamp +Proto dosTimeStamp =type fun Int -> Int =mode function =pkg core.util.zip =impl mcy =link =desc This function returns a regular timestamp from a MS-DOS timestamp. See source code for the description of MS-DOS timestamps. // +arg val =type Int =desc A MS-DOS encoded timestamp // +arg result =type Int =desc A regular timestamp (a number of seconds since 01/01/1970) // // //------------------ PROTO ----------------------------------------------------- zipExtractFiles +Proto zipExtractFiles =type fun Str Bool -> list ZipFile =mode function =pkg core.util.zip =impl mcy =link =desc This function parses a zipped content and returns the list of files, as a list of Zipfile structures. When withContent is true, the content of each [[ZipFile]] is uncompressed. Else the [[zipLoadContent]] function allows to uncompress a specific [[ZipFile]] // +arg src =type Str =desc A binary string of zipped archive // +arg withContent =type Bool =desc A boolean // +arg result =type list ZipFile =desc A list of files present in the archive // // //------------------ PROTO ----------------------------------------------------- zipLoadContent +Proto zipLoadContent =type fun Str ZipFile -> Str =mode function =pkg core.util.zip =impl mcy =link =desc When [[zipExtractFiles]] is called with withContent=false, the [[zipLoadContent]] is used to later retrieve the content of a ZipFile. // +arg src =type Str =desc A binary string of zipped archive // +arg z =type ZipFile =desc A file structure returned by a call to [[zipExtractFiles]] with the exact same src // +arg result =type Str =desc The decompressed content // // //------------------ PROTO ----------------------------------------------------- zipUpdate +Proto zipUpdate =type fun ZipFile -> Int =mode function =pkg core.util.zip =impl mcy =link =desc This function returns the timestamp of a file present in a zipped file // +arg z =type ZipFile =desc A file structure returned by [[zipExtractFiles]] // +arg result =type Int =desc A timestamp // // //------------------ PROTO ----------------------------------------------------- zipContent +Proto zipContent =type fun ZipFile -> Str =mode function =pkg core.util.zip =impl mcy =link =desc This function returns the content of a file present in a zipped file. It may return nil if the content is not yet available. Content is available only if: - function [[zipExtractFiles]] was called with withContent = true - or content was read by a call to [[zipLoadContent]] // +arg z =type ZipFile =desc A file structure returned by [[zipExtractFiles]] // +arg result =type Str =desc A string // // //------------------ PROTO ----------------------------------------------------- zipUncompressed +Proto zipUncompressed =type fun ZipFile -> Int =mode function =pkg core.util.zip =impl mcy =link =desc This function returns the size of the file before compression // +arg z =type ZipFile =desc A file structure returned by [[zipExtractFiles]] // +arg result =type Int =desc An integer // // //------------------ PROTO ----------------------------------------------------- zipCompressed +Proto zipCompressed =type fun ZipFile -> Int =mode function =pkg core.util.zip =impl mcy =link =desc This function returns the size of the file after compression // +arg z =type ZipFile =desc A file structure returned by [[zipExtractFiles]] // +arg result =type Int =desc An integer // // //------------------ PROTO ----------------------------------------------------- zipFlag +Proto zipFlag =type fun ZipFile -> Int =mode function =pkg core.util.zip =impl mcy =link =desc This function returns the zip flag of the file // +arg z =type ZipFile =desc A file structure returned by [[zipExtractFiles]] // +arg result =type Int =desc An integer // // //------------------ PROTO ----------------------------------------------------- zipFileName +Proto zipFileName =type fun ZipFile -> Str =mode function =pkg core.util.zip =impl mcy =link =desc This function returns the name of the file // +arg z =type ZipFile =desc A file structure returned by [[zipExtractFiles]] // +arg result =type Str =desc A string