Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
/ swift-xattr Public archive

Swift wrappers for Extended File Attributes handling functions setxattr, getxattr, listxattr and removexattr

License

Notifications You must be signed in to change notification settings

okla/swift-xattr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

Installation

  • Add Objective-C bridging header to your project (howto)
  • Add a line to the bridging header: #include <sys/xattr.h>
  • Add xattr.swift to your project

Usage

import Foundation

do {

  let customName = "Custom"
  let customPath = "/file.txt"
  let customData = "Custom Data".data(using: .utf8)!

  // Setting an attribute
  try Xattr.set(named: customName, data: customData, atPath: customPath)

  // Getting data from an attribute
  let data = try Xattr.dataFor(named: customName, atPath: customPath)

  // Gettings list of attributes
  let names = try Xattr.names(atPath: customPath)

  // Removing an attribute
  try Xattr.remove(named: customName, atPath: customPath)
}
catch {

  print(error.localizedDescription)
}

About

Swift wrappers for Extended File Attributes handling functions setxattr, getxattr, listxattr and removexattr

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages