gtfs/internal/zip

ZIP File Handling

Provides ZIP archive extraction using Erlang’s :zlib module. Used to load GTFS feeds from ZIP archives.

Types

Represents a ZIP archive

pub opaque type ZipArchive

Errors that can occur during ZIP operations

pub type ZipError {
  FileNotFound(filename: String)
  CorruptedArchive(reason: String)
  IoError(reason: String)
  DecompressionError(reason: String)
}

Constructors

  • FileNotFound(filename: String)

    File not found in archive

  • CorruptedArchive(reason: String)

    Archive is corrupted or invalid

  • IoError(reason: String)

    I/O error reading archive

  • DecompressionError(reason: String)

    Decompression error

Values

pub fn extract_bytes(
  archive: ZipArchive,
  filename: String,
) -> Result(BitArray, ZipError)

Extract a file from the archive as bytes

pub fn extract_matching(
  archive: ZipArchive,
  predicate: fn(String) -> Bool,
) -> Result(dict.Dict(String, String), ZipError)

Extract all files matching a predicate

pub fn extract_string(
  archive: ZipArchive,
  filename: String,
) -> Result(String, ZipError)

Extract a file from the archive as a string (UTF-8)

pub fn file_exists(archive: ZipArchive, filename: String) -> Bool

Check if a file exists in the archive

pub fn list_files(archive: ZipArchive) -> List(String)

List all files in the archive

pub fn open(data: BitArray) -> Result(ZipArchive, ZipError)

Open a ZIP archive from bytes

Search Document