Swift 6.3 · Open source · Prerelease

Give your files

a place to belong.

Work with typed files and directories, save Codable values, and handle storage failures where they happen. Cabinet brings the file management utilities from SwiftLibs into one focused Swift package.

Get started · Explore the API

import Cabinet
import Foundation

let directory = try Cabinet.Directory.applicationSupport
    .subdirectory(named: "MyApplication")
try directory.create()

let file = try directory.file(named: "greeting.txt")
try file.write(Data("Hello from Cabinet".utf8), policy: .replace)
let contents = try file.read()

Make overwrite behavior explicit

Writes fail on existing files by default. Choose .replace when the new contents should replace the previous file atomically.

Keep locations typed

Files and directories have separate types. Construct children with validated names, enumerate directories, and inspect metadata.

Save structured values

Read and write JSON with Codable, using your own encoder and decoder when the format needs customization.

Add archives when needed

Import the optional CabinetZip product for ZIP creation and extraction. Explore its API reference.

Preparing the first release

Install from the main branch while the API evolves. File operations are synchronous and report failures with thrown errors. Read the file operations guide for replacement semantics and migration notes.