Metadata-Version: 2.4
Name: cabfile
Version: 2.0.0rc1
Summary: Windows cabinet (.cab) file reader
Project-URL: Homepage, https://github.com/kristjanvalur/cabfile
Project-URL: Documentation, https://kristjanvalur.github.io/cabfile/
Author-email: Kristján Valur Jónsson <sweskman@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Kristján Valur Jónsson
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: archiving,cab,cabinet,windows
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Archiving
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# cabfile

Read Windows `.cab` archives with a small, practical API.

The modern API is centered on `CabFile` and two helpers:

- `CabFile(source)` for member listing, reading, and extraction
- `is_cabinet(source) -> bool` for safe type checks
- `probe(source) -> CabSummary` for fast cabinet-level metadata

## Quick start

```python
import cabfile

with cabfile.CabFile("archive.cab") as cab:
        print(cab.namelist())
        payload = cab.read("hello.txt")

print(cabfile.is_cabinet("archive.cab"))
summary = cabfile.probe("archive.cab")
print(summary.file_count)
```

## API shape

`CabFile` exposes two complementary layers:

- Member-centric methods for metadata + payload workflows:
    - `read_members(names=None)`
    - `extract_members(target_dir, names=None)`
- ZipFile-compatible methods/properties for drop-in usage patterns:
    - `read`, `extract`, `extractall`, `namelist`, `infolist`, `getinfo`, `printdir`, `filelist`, `NameToInfo`

## CLI

The package includes a ZipFile-style CLI via the `cabfile` script or `python -m cabfile`.

```bash
# List archive members
cabfile -l archive.cab

# Test archive readability
cabfile -t archive.cab

# Extract all members to target directory
cabfile -e archive.cab output_dir
```

Note: Exit codes are process-style:

- `0` success
- `1` test command found unreadable archive data
- `2` usage or cabinet read error

## Compatibility

Note: This project uses `ctypes` with Windows `cabinet.dll` APIs.
It is intended for Windows environments.

Note: CAB decryption/password handling is not supported.
ZipFile-shaped `pwd` parameters are accepted for compatibility but raise `NotImplementedError` when provided.

## Background

Based on the Microsoft Cabinet SDK API surface (FDI), with compatibility ideas borrowed from `zipfile.py`.
