---
title: "ZIP.Archive"
description: "ZIP archive prototype."
canonical_url: "https://www.zeyos.com/zymba/ref/zip/zip-archive"
markdown_url: "https://www.zeyos.com/ai/guide/zymba/ref/zip/zip-archive.md"
section: "zymba-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/zymbaref.json"
source_sha256: "05a361c6ddc32e74f4a6dc16fd06f218210ff1b7ce57f26ca1994bfffc407915"
---

# ZIP.Archive

## ZIP.Archive

```
object @ZIP.Archive(@Base) {
	COMPRESS_DEFAULT;
	COMPRESS_STORE;
	COMPRESS_SHRINK;
	COMPRESS_REDUCE1;
	COMPRESS_REDUCE2;
	COMPRESS_REDUCE3;
	COMPRESS_REDUCE4;
	COMPRESS_IMPLODE;
	COMPRESS_DEFLATE;
	COMPRESS_DEFLATE64;
	COMPRESS_PKWARE;
	COMPRESS_BZIP2;
	COMPRESS_LZMA;
	COMPRESS_TERSE;
	COMPRESS_LZ77;
	COMPRESS_LZMA;
	COMPRESS_ZSTD;
	COMPRESS_MP3;
	COMPRESS_XZ;
	COMPRESS_JPEG;
	COMPRESS_WAVPACK;
	COMPRESS_PPMD;
	ENCRYPT_NONE;
	ENCRYPT_PKWARE;
	ENCRYPT_AES128;
	ENCRYPT_AES128;
	ENCRYPT_AES128;
	ENCRYPT_UNKNOWN;
	MODE_READ;
	MODE_WRITE;
	MODE_CREATE;
	MODE_TRUNCATE;
	MODE_OVERWRITE;
	construct(string $path, int $mode) {}
	addDirectory(string $path, string $prefix): $this {}
	addFile(string $path, string $name): $this {}
	close() {}
	countEntries(): int {}
	crc32(string $name): int {}
	createDirectory(string $name): $this {}
	delete(string $name): $this {}
	exists(string $name): bool {}
	exit(mixed $exception) {}
	extract(object $entries, string $path): $this {}
	extractAll(string $path): $this {}
	getComment(string $name): string {}
	getCompression(string $name): int {}
	getLastModified(string $name): int {}
	getSize(string $name): int {}
	getSizeRaw(string $name): int {}
	listEntries(): object {}
	move(string $name, string $target): $this {}
	read(string $name, ?int $length): string {}
	readRaw(string $name): string {}
	restore(string $name): $this {}
	rollback(): $this {}
	selectStream(string $name): object {}
	setComment(string $name, string $comment): $this {}
	setCompression(string $name, int $method, int $flags): $this {}
	setEncryption(string $name, int $method, ?string $password): $this {}
	setLastModified(string $name, ?int $timestamp): $this {}
	setPassword(string $password): $this {}
	write(string $name, string $string): $this {}
}
```

**ZIP archive prototype.**

### Prototype

**[Base](#)**

## Methods


### `$this.construct()`


Opens a ZIP archive in a specific access mode (see MODE_* constants).

```code
$this.construct(string $path, int $mode): void
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| mode | `int`  |  | MODE_READ | MODE_WRITE | MODE_CREATE |




### `$this.addDirectory()`


```code
$this.addDirectory(string $path, string $prefix): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| prefix | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.addFile()`


```code
$this.addFile(string $path, string $name): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| name | `string`  |  | derived from path |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.close()`


Closes this archive and frees its associated resources.

```code
$this.close(): void
```




### `$this.countEntries()`


```code
$this.countEntries(): int
```

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.crc32()`


```code
$this.crc32(string $name): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.createDirectory()`


```code
$this.createDirectory(string $name): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.delete()`


```code
$this.delete(string $name): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.exists()`


```code
$this.exists(string $name): bool
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.exit()`


Closes this archive, rolls it back on failure and frees its associated resources for the purpose of contextualization.

```code
$this.exit(mixed $exception): void
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| exception | `mixed`  |  | null |




### `$this.extract()`


```code
$this.extract(object $entries, string $path): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| entries | `object`  | [name, ...] | [] |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.extractAll()`


```code
$this.extractAll(string $path): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.getComment()`


```code
$this.getComment(string $name): string
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.getCompression()`


```code
$this.getCompression(string $name): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.getLastModified()`


```code
$this.getLastModified(string $name): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.getSize()`


```code
$this.getSize(string $name): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.getSizeRaw()`


```code
$this.getSizeRaw(string $name): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.listEntries()`


```code
$this.listEntries(): object
```

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [name, ...] |




### `$this.move()`


```code
$this.move(string $name, string $target): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| target | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.read()`


```code
$this.read(string $name, ?int $length): string
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| length | `?int`  |  | maximum length |

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.readRaw()`


```code
$this.readRaw(string $name): string
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.restore()`


```code
$this.restore(string $name): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.rollback()`


Rolls back this archive by discarding all changes.

```code
$this.rollback(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.selectStream()`


```code
$this.selectStream(string $name): @IO.Stream
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `@IO.Stream` |  |




### `$this.setComment()`


```code
$this.setComment(string $name, string $comment): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| comment | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setCompression()`


```code
$this.setCompression(string $name, int $method, int $flags): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| method | `int`  |  | COMPRESS_DEFAULT |
| flags | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setEncryption()`


```code
$this.setEncryption(string $name, int $method, ?string $password): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| method | `int`  |  | ENCRYPT_NONE |
| password | `?string`  |  | archive password |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setLastModified()`


```code
$this.setLastModified(string $name, ?int $timestamp): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| timestamp | `?int`  |  | now |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setPassword()`


```code
$this.setPassword(string $password): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| password | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.write()`


```code
$this.write(string $name, string $string): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| name | `string`  |  | "" |
| string | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |
