Instance Method

createSymbolicLink(atPath:withDestinationPath:)

Creates a symbolic link that points to the specified destination.

Declaration

func createSymbolicLink(atPath path: String, withDestinationPath destPath: String) throws

Parameters

path

The path at which to create the new symbolic link. The last path component is used as the name of the link.

destPath

The path that contains the item to be pointed to by the link. In other words, this is the destination of the link.

Return Value

true if the symbolic link was created or false if an error occurred. This method also returns false if a file, directory, or link already exists at path.

Discussion

This method does not traverse symbolic links contained in destPath, making it possible to create symbolic links to locations that do not yet exist. Also, if the final path component in path is a symbolic link, that link is not followed.

See Also

Creating Symbolic and Hard Links

func createSymbolicLink(at: URL, withDestinationURL: URL)

Creates a symbolic link at the specified URL that points to an item at the given URL.

func linkItem(at: URL, to: URL)

Creates a hard link between the items at the specified URLs.

func linkItem(atPath: String, toPath: String)

Creates a hard link between the items at the specified paths.

func destinationOfSymbolicLink(atPath: String) -> String

Returns the path of the item pointed to by a symbolic link.