Structure

URLResourceValues

The properties supported by file system resources.

Overview

URLs to file system resources support the properties defined below. Note that not all property values will exist for all file system URLs. For example, if a file is located on a volume that does not support creation dates, it is valid to request the creation date property, but the returned value will be nil, and no error will be generated.

Only the fields requested by the keys you pass into the URL function to receive this value will be populated. The others will return nil regardless of the underlying property on the file system.

As a convenience, volume resource values can be requested from any file system URL. The value returned will reflect the property value for the volume on which the resource is located.

Topics

Initializers

init()

Initializes a new resource values structure.

Instance Properties

var addedToDirectoryDate: Date?

The date the resource was created, or renamed into or within its parent directory.

var allValues: [URLResourceKey : Any]

A loosely-typed dictionary containing all keys and values.

var applicationIsScriptable: Bool?

True if the resource is scriptable. Only applies to applications.

var attributeModificationDate: Date?

The time the resource’s attributes were last modified.

var canonicalPath: String?

The URL’s path as a canonical absolute file system path.

var contentAccessDate: Date?

The date the resource was last accessed.

var contentModificationDate: Date?

The time the resource content was last modified.

var creationDate: Date?

The date the resource was created.

var documentIdentifier: Int?

The document identifier – a value assigned by the kernel to a document (which can be either a file or directory) and is used to identify the document regardless of where it gets moved on a volume.

var fileAllocatedSize: Int?

Total size allocated on disk for the file in bytes (number of blocks times block size)

var fileProtection: URLFileProtection?

The protection level for this file

var fileResourceIdentifier: (NSCopying & NSSecureCoding & NSObjectProtocol)?

An identifier which can be used to compare two file system objects for equality using isEqual.

var fileResourceType: URLFileResourceType?

Returns the file system object type.

var fileSecurity: NSFileSecurity?

The file system object’s security information encapsulated in a FileSecurity object.

var fileSize: Int?

Total file size in bytes

var generationIdentifier: (NSCopying & NSSecureCoding & NSObjectProtocol)?

An opaque generation identifier which can be compared using == to determine if the data in a document has been modified.

var hasHiddenExtension: Bool?

True for resources whose filename extension is removed from the localized name property.

var isAliasFile: Bool?

true if the resource is a Finder alias file or a symlink, false otherwise

var isApplication: Bool?

True if resource is an application.

var isDirectory: Bool?

True for directories.

var isExcludedFromBackup: Bool?

True if resource should be excluded from backups, false otherwise.

var isExecutable: Bool?

True if this process (as determined by EUID) can execute a file resource or search a directory resource.

var isHidden: Bool?

True for resources normally not displayed to users.

var isMountTrigger: Bool?

True if this URL is a file system trigger directory. Traversing or opening a file system trigger will cause an attempt to mount a file system on the trigger directory.

var isPackage: Bool?

True for packaged directories.

var isReadable: Bool?

True if this process (as determined by EUID) can read the resource.

var isRegularFile: Bool?

True for regular files.

var isSymbolicLink: Bool?

True for symlinks.

var isSystemImmutable: Bool?

True for system-immutable resources.

var isUbiquitousItem: Bool?

true if this item is synced to the cloud, false if it is only a local file.

var isUserImmutable: Bool?

True for user-immutable resources

var isVolume: Bool?

True for the root directory of a volume.

var isWritable: Bool?

True if this process (as determined by EUID) can write to the resource.

var labelNumber: Int?

The label number assigned to the resource.

var linkCount: Int?

Number of hard links to the resource.

var localizedLabel: String?

The user-visible label text.

var localizedName: String?

Localized or extension-hidden name as displayed to users.

var localizedTypeDescription: String?

User-visible type or “kind” description.

var name: String?

The resource name provided by the file system.

var parentDirectory: URL?

The resource’s parent directory, if any.

var path: String?

The URL’s path as a file system path.

var preferredIOBlockSize: Int?

The optimal block size when reading or writing this file’s data, or nil if not available.

var quarantineProperties: [String : Any]?

The quarantine properties as defined in LSQuarantine.h. To remove quarantine information from a file, pass nil as the value when setting this property.

var tagNames: [String]?

The array of Tag names.

var totalFileAllocatedSize: Int?

Total allocated size of the file in bytes (this may include space used by metadata), or nil if not available. This can be less than the value returned by totalFileSize if the resource is compressed.

var totalFileSize: Int?

Total displayable size of the file in bytes (this may include space used by metadata), or nil if not available.

var typeIdentifier: String?

Uniform type identifier (UTI) for the resource.

var ubiquitousItemContainerDisplayName: String?

returns the name of this item’s container as displayed to users.

var ubiquitousItemDownloadRequested: Bool?

returns whether a download of this item has already been requested with an API like startDownloadingUbiquitousItem(at:) throws.

var ubiquitousItemDownloadingError: NSError?

returns the error when downloading the item from iCloud failed, see the NSUbiquitousFile section in FoundationErrors.h

var ubiquitousItemHasUnresolvedConflicts: Bool?

true if this item has conflicts outstanding.

var ubiquitousItemIsDownloading: Bool?

true if data is being downloaded for this item.

var ubiquitousItemIsUploaded: Bool?

true if there is data present in the cloud for this item.

var ubiquitousItemIsUploading: Bool?

true if data is being uploaded for this item.

var ubiquitousItemUploadingError: NSError?

returns the error when uploading the item to iCloud failed, see the NSUbiquitousFile section in FoundationErrors.h

var volume: URL?

URL of the volume on which the resource is stored.

var volumeAvailableCapacity: Int?

Total free space in bytes.

var volumeCreationDate: Date?

The volume’s creation date, or nil if this cannot be determined.

var volumeIdentifier: (NSCopying & NSSecureCoding & NSObjectProtocol)?

An identifier that can be used to identify the volume the file system object is on.

var volumeIsAutomounted: Bool?

true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey.

var volumeIsBrowsable: Bool?

true if the volume should be visible via the GUI (i.e., appear on the Desktop as a separate volume).

var volumeIsEjectable: Bool?

true if the volume’s media is ejectable from the drive mechanism under software control.

var volumeIsEncrypted: Bool?

true if the volume is encrypted.

var volumeIsInternal: Bool?

true if the volume’s device is connected to an internal bus, false if connected to an external bus, or nil if not available.

var volumeIsJournaling: Bool?

true if the volume is currently using a journal for speedy recovery after an unplanned restart.

var volumeIsLocal: Bool?

true if the volume is stored on a local device.

var volumeIsReadOnly: Bool?

true if the volume is read-only.

var volumeIsRemovable: Bool?

true if the volume’s media is removable from the drive mechanism.

var volumeIsRootFileSystem: Bool?

true if the volume is the root filesystem.

var volumeLocalizedFormatDescription: String?

The user-visible volume format.

var volumeLocalizedName: String?

The user-presentable name of the volume

var volumeMaximumFileSize: Int?

The largest file size (in bytes) supported by this file system, or nil if this cannot be determined.

var volumeName: String?

The name of the volume

var volumeResourceCount: Int?

Total number of resources on the volume.

var volumeSupportsAdvisoryFileLocking: Bool?

true if the volume implements whole-file flock(2) style advisory locks, and the O_EXLOCK and O_SHLOCK flags of the open(2) call.

var volumeSupportsCasePreservedNames: Bool?

true if the volume format preserves the case of file and directory names. Otherwise the volume may change the case of some characters (typically making them all upper or all lower case).

var volumeSupportsCaseSensitiveNames: Bool?

true if the volume format treats upper and lower case characters in file and directory names as different. Otherwise an upper case character is equivalent to a lower case character, and you can’t have two names that differ solely in the case of the characters.

var volumeSupportsCompression: Bool?

true if the volume supports transparent decompression of compressed files using decmpfs.

var volumeSupportsExtendedSecurity: Bool?

true if the volume implements extended security (ACLs).

var volumeSupportsHardLinks: Bool?

true if the volume format supports hard links.

var volumeSupportsJournaling: Bool?

true if the volume format supports a journal used to speed recovery in case of unplanned restart (such as a power outage or crash). This does not necessarily mean the volume is actively using a journal.

var volumeSupportsPersistentIDs: Bool?

true if the volume format supports persistent object identifiers and can look up file system objects by their IDs.

var volumeSupportsRenaming: Bool?

true if the volume can be renamed.

var volumeSupportsRootDirectoryDates: Bool?

true if the volume supports reliable storage of times for the root directory.

var volumeSupportsSparseFiles: Bool?

true if the volume format supports sparse files, that is, files which can have ‘holes’ that have never been written to, and thus do not consume space on disk. A sparse file may have an allocated size on disk that is less than its logical length.

var volumeSupportsSymbolicLinks: Bool?

true if the volume format supports symbolic links.

var volumeSupportsVolumeSizes: Bool?

true if the volume supports returning volume size values (volumeTotalCapacity and volumeAvailableCapacity).

var volumeSupportsZeroRuns: Bool?

For security reasons, parts of a file (runs) that have never been written to must appear to contain zeroes. true if the volume keeps track of allocated but unwritten runs of a file so that it can substitute zeroes without actually writing zeroes to the media.

var volumeTotalCapacity: Int?

Total volume capacity in bytes.

var volumeURLForRemounting: URL?

The URL needed to remount a network volume, or nil if not available.

var volumeUUIDString: String?

The volume’s persistent UUID as a string, or nil if a persistent UUID is not available for the volume.

See Also

Accessing Resource Values

func resourceValues(forKeys: Set<URLResourceKey>)

Return a collection of resource values identified by the given resource keys.

func setResourceValues(URLResourceValues)

Sets the resource value identified by a given resource key.

func removeCachedResourceValue(forKey: URLResourceKey)

Removes the cached resource value identified by a given resource value key from the URL object.

func removeAllCachedResourceValues()

Removes all cached resource values and all temporary resource values from the URL object.

func setTemporaryResourceValue(Any, forKey: URLResourceKey)

Sets a temporary resource value on the URL object.

struct URLResourceKey

Keys that apply to file system URLs.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software