How Unrar Extracts macOS Resource Forks

This article provides an overview of how the unrar utility processes, translates, and restores macOS resource forks and extended metadata. macOS files historically utilized a dual-fork structure—a data fork and a resource fork—which modern Apple file systems represent as extended attributes. When unpacking archives on Apple systems, unrar identifies specialized metadata blocks inside the RAR archive and uses native operating system APIs to reattach this metadata to the target files.

The Structure of macOS Resource Forks

In classic Macintosh file systems (such as HFS) and continuing into modern file systems (HFS+ and APFS), files can store data across two separate streams:

  • Data Fork: Contains the primary payload of the file (e.g., standard text, executable code, or media).
  • Resource Fork: Contains structured metadata, such as UI elements, icons, font metrics, application code, and extended attributes.

On modern macOS systems (APFS), the legacy resource fork is encapsulated under extended attributes (xattrs), specifically under the named attribute com.apple.ResourceFork.

How RAR Archives Store Mac Metadata

When creating a RAR archive on macOS, the archiver reads both the standard data stream and the file's extended attributes. RAR stores these extra streams inside distinct metadata sub-blocks within the file entry.

These sub-blocks define:

  • The attribute type (such as Extended Attribute or Mac Resource Fork).
  • The size and checksum of the attribute payload.
  • The specific naming conventions required to restore the fork accurately.

Extraction Mechanism in Unrar

When unrar processes an archive containing macOS-specific records, it executes the following steps:

  1. Header Inspection: unrar reads the file header and parses any extra sub-headers. If a sub-header signifies extended attributes or a macOS resource fork, unrar isolates this data stream from the main data fork.
  2. Platform Detection: The utility checks whether the target environment natively supports macOS extended attributes.
  3. Primary Data Extraction: The data fork is extracted first, creating the standard file entry on the host filesystem.
  4. Applying the Resource Fork via Native APIs:
    • On macOS, unrar leverages POSIX-compliant extended attribute system calls—primarily setxattr().
    • It writes the stored resource stream directly to the target file using the attribute key com.apple.ResourceFork.
    • Any additional file metadata, such as Finder flags (com.apple.FinderInfo) or quarantine markers, are similarly reconstructed using corresponding setxattr() calls.

Behavior on Non-macOS Systems

When unrar runs on platforms that do not natively support Apple's dual-fork model (such as standard Linux or Windows):

  • By default, unrar may skip the com.apple.ResourceFork blocks because the host filesystem lacks the necessary interface to attach them directly.
  • Depending on compilation options and CLI flags, non-native extractions may convert this metadata into AppleDouble format files. In this scenario, the main data fork is extracted normally, and the resource fork/metadata is saved as a companion file prefixed with ._ (for example, file.ext and ._file.ext).