<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/dispatch_io_create_with_path",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "c:@F@dispatch_io_create_with_path"
  },
  "title" : "dispatch_io_create_with_path"
}
-->

# dispatch_io_create_with_path

Creates a dispatch I/O channel with the associated path name.

```
extern dispatch_io_tdispatch_io_create_with_path(dispatch_io_type_t type, const char *path, int oflag, mode_t mode, dispatch_queue_t queue, void (^cleanup_handler)(int error));
```

## Parameters

`type`

The type of channel to create. For a list of possible options, see [`dispatch_io_type_t`](/documentation/Dispatch/dispatch_io_type_t).

`path`

The file system path to open and use for the channel I/O. This path is opened using the open system call.

`oflag`

The flags to pass to the open function when opening the path.

`mode`

The mode to pass to the open function when creating a file at the specified path. If you are not creating a file, specify `0`.

`queue`

The dispatch queue to associate with the channel. This queue is used to execute the channel’s clean up handler. The channel retains this queue.

`cleanup_handler`

The block to enqueue when the system relinquishes control of the channel’s file descriptor. This channel takes a single parameter that indicates the reason why control was relinquished. If the `error` parameter contains a non zero value, control was relinquished because there was an error creating the channel; otherwise, this value should be `0`.

## Return Value

The dispatch I/O channel or `NULL` if an error occurred. The returned object is retained before it is returned; it is your responsibility to close the channel and then release this object when you are done using it.

## Discussion

This function associates the specified path with the channel but does not open a file descriptor for that path until you perform the first I/O operation. While it is open, the channel owns the file descriptor. The channel closes the file descriptor and calls its cleanup handler when one of the following occurs:

- You close the channel by calling the [`dispatch_io_close`](/documentation/Dispatch/dispatch_io_close) function.
- An unrecoverable error occurs on the file descriptor.
- All references to the channel are released.

---

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)