ZipArchive Class - raravel/libzip GitHub Wiki
This class like C# ZipArchive
Represents a package of compressed files in the zip archive format.
Properties
Entries ( get )
Type: ZipArchiveEntry Array The collection of entries that are currently in the zip archive.
Password ( get/set )
Type: String The password of zip file for en/decryption.
Filename ( get/set )
Type: String The filename (include directory) of zip file.
Stream ( get )
Type: Buffer Zip file buffer.
Methods
GetEntry
Retrieves a wrapper for the specified entry in the zip archive.
Source: libzip.ts:326
Arguments
| Type | Name | Description | Necessary |
|---|---|---|---|
| String | entryName | Entry name | TRUE |
Example
import { ZipFile, ZipArchive, ZIpArchiveEntry } from 'libzip';
const archive: ZipArchive = ZipFile.Open('zip file.zip');
const entry: ZipArchiveEntry = archive.GetEntry('entry name');
CreateEntry
Creates an empty entry in the zip archive.
Source: libzip.ts:333
Arguments
| Type | Name | Description | Necessary |
|---|---|---|---|
| String | entryName | Name of new entry | TRUE |
Example
import { ZipFile, ZipArchive, ZIpArchiveEntry } from 'libzip';
const archive: ZipArchive = ZipFile.Open('zip file.zip');
const entry: ZipArchiveEntry = archive.CreateEntry('entry name');
ExtractAll
Extracts all the files in the specified zip archive to a directory on the file system.
Source: libzip.ts:360
Arguments
| Type | Name | Description | Necessary |
|---|---|---|---|
| String | dir | Extract target directory | FALSE |
Example
import { ZipFile, ZipArchive } from 'libzip';
const archive: ZipArchive = ZipFile.Open('zip file path.zip');
archive.ExtractAll('./dst path');
/* do something */
Save
Just save zip file.
Source: libzip.ts:381
Arguments
| Type | Name | Description | Necessary |
|---|
Example
import { ZipFile, ZipArchive } from 'libzip';
const archive: ZipArchive = ZipFile.Open('zip file path.zip');
// save as
archive.Filename = 'change name';
archive.save();
/* do something */