Skip to content

Copy file data and/or metadata using copyfile(3) on macOS

Notifications You must be signed in to change notification settings

inopinatus/copyfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copyfile

Copy file data and/or metadata using copyfile(3) on macOS.

Installation

Prerequisites

  • macOS 10.12 (Sierra) or later
  • Xcode and the Command Line Tools installed

From source

Clone the repository and navigate to the project directory:

git clone https://github.com/inopinatus/copyfile.git
cd copyfile

Compile and install:

make install

Now, you should be able to use copyfile from anywhere in your terminal. By default, files will be installed under /usr/local. You can adjust locations using the variables in the Makefile, e.g. make install PREFIX=/opt.

Usage

copyfile src dst [flags...]

The arguments have the same meaning as those passed to the copyfile(3) library function. The src and dst are paths. The flags option accepts a list of space-separated strings matching those of the library call, and may be any of:

acl stat xattr data security metadata all nofollow_src nofollow_dst nofollow excl move unlink pack unpack check clone clone_force verbose recursive data_sparse run_in_place preserve_dst_tracked

See copyfile(3) for the documented meaning of these flags.

Note that only specified contents is copied. If no flags are given, then no contents will be copied, but the destination may be created if it does not already exist.

Examples

  1. Copy a file and its metadata:
copyfile file1.txt file2.txt all
  1. Copy only the metadata of one file to another, leaving the destination's data intact:
copyfile original.png revised.jpg metadata
  1. Attempt to recursively clone a hierarchy, including metadata, with fallback to a sparse-aware regular copy:
copyfile ~/src ~/tmp/src.backup recursive data_sparse clone

Exit Status

The copyfile utility exits with 0 on success, or >0 if an error occurs.

Callbacks

The callback behaviours in the copyfile(3) library are not available through this utility.

License

This version of copyfile is adapted directly from test code included in Apple OSS releases, and therefore distributed under the Apple Public Source License.

Contributing

Bug reports and pull requests are welcome on Github at https://github.com/inopinatus/copyfile

About

Copy file data and/or metadata using copyfile(3) on macOS

Resources

Stars

Watchers

Forks