Class

NSFileWrapper

The NSFileWrapper class provides access to the attributes and contents of file-system nodes. A file-system node is a file, directory, or symbolic link. Instances of this class are known as file wrappers.

Overview

File wrappers represent a file-system node as an object that can be displayed as an image (and possibly edited in place), saved to the file system, or transmitted to another application.

There are three types of file wrappers:

  • Regular-file file wrapper: Represents a regular file.

  • Directory file wrapper: Represents a directory.

  • Symbolic-link file wrapper: Represents a symbolic link.

A file wrapper has these attributes:

  • Filename. Name of the file-system node the file wrapper represents.

  • file-system attributes. See NSFileManager for information on the contents of the attributes dictionary.

  • Regular-file contents. Applicable only to regular-file file wrappers.

  • File wrappers. Applicable only to directory file wrappers.

  • Destination node. Applicable only to symbolic-link file wrappers.

Symbols

Creating File Wrappers

This class has several designated initializers.

- initWithURL:options:error:

Initializes a file wrapper instance whose kind is determined by the type of file-system node located by the URL.

- initWithPath:

Initializes a file wrapper instance whose kind is determined by the type of file-system node located by the path.

Deprecated
- initDirectoryWithFileWrappers:

Initializes the receiver as a directory file wrapper, with a given file-wrapper list.

- initRegularFileWithContents:

Initializes the receiver as a regular-file file wrapper.

- initSymbolicLinkWithDestination:

Initializes the receiver as a symbolic-link file wrapper.

Deprecated
- initSymbolicLinkWithDestinationURL:

Initializes the receiver as a symbolic-link file wrapper that links to a specified file.

- initWithSerializedRepresentation:

Initializes the receiver as a regular-file file wrapper from given serialized data.

Querying File Wrappers

regularFile

This property contains a boolean value that indicates whether the file wrapper object is a regular-file.

directory

This property contains a boolean value indicating whether the file wrapper is a directory file wrapper.

symbolicLink

A boolean that indicates whether the file wrapper object is a symbolic-link file wrapper.

Accessing File-Wrapper Information

fileWrappers

The file wrappers contained by a directory file wrapper.

- addFileWrapper:

Adds a child file wrapper to the receiver, which must be a directory file wrapper.

- removeFileWrapper:

Removes a child file wrapper from the receiver, which must be a directory file wrapper.

- addFileWithPath:

Creates a file wrapper from a given file-system node and adds it to the receiver, which must be a directory file wrapper.

Deprecated
- addRegularFileWithContents:preferredFilename:

Creates a regular-file file wrapper with the given contents and adds it to the receiver, which must be a directory file wrapper.

- addSymbolicLinkWithDestination:preferredFilename:

Creates a symbolic-link file wrapper pointing to a given file-system node and adds it to the receiver, which must be a directory file wrapper.

Deprecated
- keyForFileWrapper:

Returns the dictionary key used by a directory to identify a given file wrapper.

- symbolicLinkDestination

Provides the pathname referenced by the file wrapper object, which must be a symbolic-link file wrapper.

Deprecated
symbolicLinkDestinationURL

The URL referenced by the file wrapper object, which must be a symbolic-link file wrapper.

Updating File Wrappers

- needsToBeUpdatedFromPath:

Indicates whether the file wrapper needs to be updated to match a given file-system node.

Deprecated
- matchesContentsOfURL:

Indicates whether the contents of a file wrapper matches a directory, regular file, or symbolic link on disk.

- updateFromPath:

Updates the file wrapper to match a given file-system node.

Deprecated
- readFromURL:options:error:

Recursively rereads the entire contents of a file wrapper from the specified location on disk.

Serializing

serializedRepresentation

The contents of the file wrapper as an opaque collection of data.

Accessing Files

filename

The filename of the file wrapper object

preferredFilename

The preferred filename for the file wrapper object.

fileAttributes

A dictionary of file attributes.

regularFileContents

The contents of the file-system node associated with a regular-file file wrapper.

Writing Files

- writeToFile:atomically:updateFilenames:

Writes a file wrapper’s contents to a given file-system node.

Deprecated
- writeToURL:options:originalContentsURL:error:

Recursively writes the entire contents of a file wrapper to a given file-system URL.

Working with Icons

icon

The icon that represents the file wrapper.

Constants

Initializers

Relationships

Inherits From

Conforms To