---
title: "completeIO(for:offset:length:status:flags:operationID:replyHandler:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsvolume/kerneloffloadediohandler/completeio(for:offset:length:status:flags:operationid:replyhandler:)"
---

# completeIO(for:offset:length:status:flags:operationID:replyHandler:)

Completes an I/O operation for a given file.

## Declaration

```swift
func completeIO(for file: FSItem, offset: off_t, length: Int, status: any Error, flags: FSCompleteIOFlags, operationID: FSOperationID, replyHandler reply: @escaping @Sendable (FSCompleteIOResult?, (any Error)?) -> Void)
```

```swift
func completeIO(for file: FSItem, offset: off_t, length: Int, status: any Error, flags: FSCompleteIOFlags, operationID: FSOperationID) async throws -> FSCompleteIOResult
```

## Parameters

- `file`: The file for which the I/O operation completed.
- `offset`: The starting logical offset at which I/O started.
- `length`: The length of the I/O range (in bytes).
- `status`: Any error that occurred during the operation. If no error occurred, this parameter is nil.
- `flags`: Flags that affect the behavior of the complete I/O operation.
- `operationID`: A unique identifier of the blockmap call. Any value other than 0 (Objective-C) or doc://FSKit/documentation/FSKit/FSOperationID/unspecified (Swift) corresponds to a previous call to doc://FSKit/documentation/FSKit/FSVolume/KernelOffloadedIOHandler/blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:) with the same operationID.

## Discussion

Discussion ::::: Swift :::::::::: reply: A block or closure to indicate success or failure. If completing I/O succeeds, pass an instance of FSCompleteIOResult containing the updated FSItem.Attributes of the file, along with a nil error. If completing I/O fails, pass the relevant error as the second parameter; FSKit ignores the FSCompleteIOResult instance in this case. For an async Swift implementation, there’s no reply handler; simply return the result instance or throw an error. :::::::::::::::::::: ::::: ObjC :::::::::: result: A block or closure to indicate success or failure. If completing I/O succeeds, pass an instance of FSCompleteIOResult containing the updated FSItem.Attributes of the file, along with a nil error. If completing I/O fails, pass the relevant error as the second parameter; FSKit ignores the FSCompleteIOResult instance in this case. For an async Swift implementation, there’s no reply handler; simply return the result instance or throw an error. :::::::::::::::::::: Discussion Implement this method by updating a file’s metadata, such as its size and modification time. FSKit may call this method without an earlier call to blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:). In this case, the operationID is 0 (Objective-C) or unspecified (Swift).

## See Also

### Performing mapped I/O

- [blockmapFile(_:offset:length:flags:operationID:packer:replyHandler:)](fskit/fsvolume/kerneloffloadediohandler/blockmapfile(_:offset:length:flags:operationid:packer:replyhandler:).md)
- [FSBlockmapFlags](fskit/fsblockmapflags.md)
- [FSBlockmapResult](fskit/fsblockmapresult.md)
- [FSCompleteIOFlags](fskit/fscompleteioflags.md)
- [FSCompleteIOResult](fskit/fscompleteioresult.md)
