GithubHelp home page GithubHelp logo

sindresorhus / extendedattributes Goto Github PK

View Code? Open in Web Editor NEW
43.0 3.0 2.0 11 KB

Manage extended attributes in Swift

Home Page: https://swiftpackageindex.com/sindresorhus/ExtendedAttributes/documentation/extendedattributes

License: MIT License

Swift 100.00%
extended-attributes file-system swift swift-package swift-package-manager metadata

extendedattributes's Introduction

extendedattributes's People

Contributors

sindresorhus avatar

Stargazers

haruna avatar  avatar Thomas Soteros avatar Vikram Kriplaney avatar Josh Klein avatar Ryan Robinson avatar Aileon avatar vancaem avatar Thomas Harr avatar mdewar avatar Alexander Lester avatar Mx-Iris avatar Konstantin Pavlikhin avatar Maxim Kotliar avatar Pat Nakajima avatar Meiji Hatakeyama avatar Zhazha_JiaYiZhen avatar Moinul Moin avatar  avatar Max Garber avatar  avatar  avatar  avatar Daniel Marriner avatar  avatar Ben Roberts avatar Saqib Saleem avatar David Bureš avatar Nathan Manceaux-Panot avatar Bing ZHEUNG avatar Jaume Corbi avatar Wes Souza avatar Pedro José Pereira Vieito avatar Finn Voorhees avatar Christian Owusu avatar Johannes Jakob avatar Cao Phuoc Thanh avatar Muhammad Umer avatar baegteun avatar Noel Towa avatar houseme avatar Samuel Burkhard avatar Saumya avatar

Watchers

 avatar  avatar Chase Knowlden avatar

extendedattributes's Issues

Strongly-typed metadata names

It would be useful to be able to define strongly-typed keys that know how to decode/encode the value.

import ExtendedAttributes

extension SystemMetadata.Name {
	/**
	App used to create the document content (for example “Word”, “Pages”, and so on).
	*/
	static let itemCreator = Self(kMDItemCreator as String, type: String.self)
}

let fileURL = URL(fileURLWithPath: "/path/to/file")
let ItemCreator = try? fileURL.systemMetadata.get(.itemCreator)

We could even include some common ones, like the ones in: https://developer.apple.com/documentation/coreservices/file_metadata/mditem/common_metadata_attribute_keys


Feedback wanted

Strongly-typed extended attribute names

It would be useful to be able to define strongly-typed keys that know how to decode/encode the value.

import ExtendedAttributes

extension ExtendedAttributes.Name {
	static let isProtected = Self(
		get: { api in
			try api.getPropertyListSerializedValue("com.apple.rootless", type: Bool.self) ?? false
		},
		set: { api, value, flags in
			try api.setPropertyListSerializedValue("com.apple.rootless", value: value, flags: flags)
		}
	)
}

let fileURL = URL(fileURLWithPath: "/path/to/file")
let isProtected = try? fileURL.extendedAttributes.get(.isProtected)

We could even include some common ones.


Feedback wanted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.