ddn-lib-dar ~main

libdar binding to D


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

ddn-lib-dar

D language bindings for libdar — the Disk ARchive library.

ddn-lib-dar provides comprehensive D bindings to libdar, enabling D developers to create, read, and manipulate DAR archives with an idiomatic, type-safe API. The library offers both low-level bindings (ddn.lib.dar) for direct control and a high-level wrapper (ddn.wrp.dar) with RAII resource management, range-based iteration, and fluent option builders.

libdar

DAR (Disk ARchive) is a powerful, feature-rich backup and archiving tool created by Denis Corbin. Unlike tar, DAR supports:

  • Differential and incremental backups — only store changed files
  • Strong encryption — AES-256, Blowfish, Twofish, Serpent, Camellia
  • Compression — gzip, bzip2, xz, lz4, zstd
  • Slicing — split archives across multiple volumes/media
  • Extended attributes and ACLs — full filesystem metadata preservation
  • On-the-fly integrity checking — detect corruption early
  • Catalogue isolation — extract archive metadata for fast browsing

The upstream DAR project is hosted at:

  • Git Repository: https://github.com/Edrusb/DAR
  • Website: http://dar.linux.free.fr

Installation

Prerequisites

Install libdar development headers on your system:

# Fedora/RHEL
sudo dnf install libdar libdar-devel

# Debian/Ubuntu
sudo apt install libdar64-dev

# Arch Linux
sudo pacman -S dar

However, for anything more serious than "hello DAR world" you would need some extra libraries. This is what I typically do on Fedora and derivatives:

sudo dnf intall libargon2-devel gpgme-devel librsync-devel libattr-devel rhash-devel \
  libgcrypt-devel libgpg-error-devel

Using DUB

Add ddn-lib-dar as a dependency in your dub.sdl:

name "my-backup-app"
description "My backup application"
dependency "ddn-lib-dar" version="~>1.0"

Or in dub.json:

{
    "name": "my-backup-app",
    "dependencies": {
        "ddn-lib-dar": "~>1.0"
    }
}

Demo

Here is a minimal example demonstrating archive creation, listing, and extraction using the high-level ddn.wrp.dar API. The complete source is available in demo/ddn/wrp/dar_intro.d.

Project Setup (dub.sdl)

name "dar-demo"
description "DAR archive demo"
dependency "ddn-lib-dar" version="~>1.0"
targetType "executable"
targetName "dar-demo"

Example Code

import ddn.wrp.dar;
import std.stdio;

void main()
{
    // 1. Create an archive with compression
    auto createOptions = createOpts()
        .withCompression(DarCompression.GZIP)
        .withCompressionLevel(6)
        .withAllowOverwrite(true)
        .toLow();

    auto archive = Archive.create(
        "/home/user/documents",  // Source directory
        "/backups",              // Output directory
        "docs_backup",           // Archive base name
        "dar",                   // Extension
        createOptions
    );

    if (archive.isValid)
        writeln("Archive created successfully!");
    archive.close();

    // 2. Open and list archive contents
    auto readOptions = readOpts()
        .withExtension("dar")
        .toLow();

    auto arc = Archive.open("/backups", "docs_backup", "dar", readOptions);

    foreach (entry; arc.list())
    {
        writefln("  %s: %s (%d bytes)",
            entry.entryType == DarEntryType.FILE ? "FILE" : "DIR",
            entry.name,
            entry.size);
    }

    // 3. Extract the archive
    arc.extract("/home/user/restored");

    // 4. Test archive integrity
    auto result = arc.test();
    if (result.errors == 0)
        writefln("Archive OK: %d files verified", result.filesChecked);
}

Features

The following table lists libdar features and their implementation status in ddn-lib-dar:

FeatureImplementedNotes
Archive creation (full backup)Yes
Archive reading/openingYes
Archive listingYesRange-based iteration
Archive extractionYesWith filtering support
Archive testing (integrity)Yes
Differential/incremental backupsYesVia reference archive
Archive mergingYes
Archive comparison (diff)Yes
Catalogue isolationYes
Archive repairYes
Compression (gzip, bzip2, xz, lz4, zstd)YesAll algorithms supported
Encryption (AES, Blowfish, Twofish, etc.)YesAll algorithms supported
Slicing (multi-volume archives)Yes
Delta/binary diff (librsync)YesIf libdar built with librsync
Extended attributes (EA)Yes
Filesystem-specific attributes (FSA)Yes
ACL preservationYes
Sparse file handlingYes
Hard link preservationYes
Symlink handlingYes
Include/exclude filtersYesGlob and regex patterns
Path-based filteringYes
dar_manager databaseYesFull API
dar_xform (re-slicing)YesPath, pipe, and FD modes
dar_slave (remote serving)YesPipe and FD modes
User interaction callbacksYesFull class support
Progress callbacksYes
Compile-time feature detectionYes
Sequential read modeYesFor tape/streaming
Hash/checksum sidecar filesYesMD5, SHA1, SHA256, SHA512
Secure password handlingYesSecurePassword class
Custom overwrite policiesYes
Empty directory handlingYes
Unix socket handlingYes
Remote repositories (FTP/SFTP)PartialURL configuration only
Thread cancellationNoNot exposed
Custom entrepôt implementationsNo

API Modules

ModuleDescription
ddn.lib.darLow-level bindings with direct C shim access
ddn.wrp.darHigh-level wrapper with RAII, ranges, and fluent builders

For detailed API documentation and tutorials, see:

License

This project was originally intended to be released under the BSD-3-Clause license. However, since DAR and libdar are released under the GNU General Public License (GPL), any code that links against libdar must also be covered by the GPL or a GPL-compatible license. Therefore, ddn-lib-dar is licensed under the GPL.

See the LICENSE file for the full license text.

See Also

Authors:
  • Dejan Lekić
Dependencies:
none
Versions:
2.8.1 2025-Dec-05
~main 2025-Dec-05
Show all 2 versions
Download Stats:
  • 2 downloads today

  • 2 downloads this week

  • 2 downloads this month

  • 2 downloads total

Score:
0.0
Short URL:
ddn-lib-dar.dub.pm