<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManagerDelegate/fileManager(_:shouldLinkItemAtPath:toPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSFileManagerDelegate(im)fileManager:shouldLinkItemAtPath:toPath:"
  },
  "title" : "fileManager(_:shouldLinkItemAtPath:toPath:)"
}
-->

# fileManager(_:shouldLinkItemAtPath:toPath:)

Asks the delegate if a hard link should be created between the items at the two paths.

```
optional func fileManager(_ fileManager: FileManager, shouldLinkItemAtPath srcPath: String, toPath dstPath: String) -> Bool
```

## Parameters

`fileManager`

The file manager object that is attempting to create the link.

`srcPath`

The path or a file or directory that `fileManager` is about to attempt to link.

`dstPath`

The path or a file or directory to which `fileManager` is about to attempt to link.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the operation should proceed, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If the item specified by `destURL` is a directory, returning <doc://com.apple.documentation/documentation/Swift/false> prevents links from being created to both the directory and its children.

This method performs the same task as the [`fileManager(_:shouldLinkItemAt:to:)`](/documentation/Foundation/FileManagerDelegate/fileManager(_:shouldLinkItemAt:to:)) method, which is preferred over this method in macOS 10.6 and later.

## See Also

[`-  linkItemAtURL:toURL:error:`](/documentation/Foundation/FileManager/linkItem(at:to:))

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

[`-  linkItemAtPath:toPath:error:`](/documentation/Foundation/FileManager/linkItem(atPath:toPath:))

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)