Contents

setAttributes(_:ofItemAtPath:)

Sets the attributes of the specified file or directory.

Declaration

func setAttributes(_ attributes: [FileAttributeKey : Any], ofItemAtPath path: String) throws

Parameters

Discussion

As in the POSIX standard, the app either must own the file or directory or must be running as superuser for attribute changes to take effect. The method attempts to make all changes specified in attributes and ignores any rejection of an attempted modification. If the last component of the path is a symbolic link, the system traverses it.

You must initialize the posixPermissions value with the code representing the POSIX file-permissions bit pattern. The system sets hfsCreatorCode and hfsTypeCode only when path specifies a file.

See Also

Getting and setting attributes