Retired Document
Important: This document may not represent best practices for current development. For current information, see About Apple File System.
Tools and APIs
Conversion Tool
- hfs_convert_apfs
hfs_convert_apfs
Disk Image Tools
- diskutil apfs …
diskutil apfs createContainer /dev/disk1s1
diskutil apfs addVolume disk1s1 APFS newAPFS
- hdiutil
hdiutil create -fs APFS -size 1GB foo.sparseimage
- fsck_apfs
fsck_apfs
Enhanced APIs
- Foundation / FileManager
func copyItem(atPath srcPath: String,
toPath dstPath: String) throws
func replaceItem(at originalItemURL: URL,
withItemAt newItemURL: URL,
backupItemName backupItemName: String?,
options options:
FileManager.ItemReplacementOptions = [],
resultingItemURL resultingURL:
AutoreleasingUnsafeMutablePointer<NSURL?>?) throws
- libcopyfile
#include <copyfile.h>
int copyfile(const char *from,
const char *to,
copyfile_state_t state,
copyfile_flags_t flags);
int fcopyfile(int from_fd,
int to_fd,
copyfile_state_t state,
copyfile_flags_t flags);
// new flag bit: COPYFILE_CLONE
// equivalent to (COPYFILE_EXCL | COPYFILE_ACL | COPYFILE_STAT | COPYFILE_XATTR | COPYFILE_DATA)
- Safe Save APIs
#include <stdio.h>
int renamex_np(const char *, const char *, unsigned int)
int renameatx_np(int, const char *, int, const char *, unsigned int)
- Cloning APIs
#include <sys/attr.h>
#include <sys/clonefile.h>
int clonefileat(int, const char *, int, const char *, uint32_t);
int fclonefileat(int, int, const char *, uint32_t);
int clonefile(const char *, const char *, uint32_t);
Copyright © 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-06-04