npm.io
2.0.5 • Published 11 months ago

rclonefile

Licence
MIT
Version
2.0.5
Deps
0
Size
30 kB
Vulns
0
Weekly
0
Stars
19

rclonefile

The macOS API for creating copy on write clones of files.

Description

This is a small wrapper around the clonefile API on macOS for cloning files using the APFS file system.

Usage

async/await

import { cloneFile } from "rclonefile";

await cloneFile("source/mario.txt", "target/mario-clone-txt");
Promise

import { cloneFile } from "rclonefile";

cloneFile("source/mario.txt", "target/mario-clone-txt").then(() => {
	// Success
})
Sync API

import { cloneFileSync } from "rclonefile";

cloneFileSync("source/mario.txt", "target/mario-clone-txt");

Options

All functions accept an optional third argument with the following options:

interface CloneFileOptions {
  noFollow?: boolean;    // Don't follow symlinks, clone the link itself
  noOwnerCopy?: boolean; // Don't copy ownership information
  cloneAcl?: boolean;    // Clone ACL (Access Control List) information
}
Example with options
import { cloneFile } from "rclonefile";

// Clone a symlink as a symlink (don't follow it)
await cloneFile("source/link.txt", "target/link.txt", { noFollow: true });

// Clone without copying ownership
await cloneFile("source/file.txt", "target/file.txt", { noOwnerCopy: true });