<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FSKit",
  "identifier" : "/documentation/FSKit/FSVolume/ReadWriteHandler/read(from:at:length:into:replyHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "FSKit"
    ],
    "preciseIdentifier" : "c:objc(pl)FSVolumeReadWriteHandler(im)readFromFile:offset:length:intoBuffer:replyHandler:"
  },
  "title" : "read(from:at:length:into:replyHandler:)"
}
-->

# read(from:at:length:into:replyHandler:)

Reads the contents of the given file item.

```
func read(from item: FSItem, at offset: off_t, length: Int, into buffer: FSMutableFileDataBuffer, replyHandler reply: @escaping @Sendable (FSReadFileResult?, (any Error)?) -> Void)
```

```
func read(from item: FSItem, at offset: off_t, length: Int, into buffer: FSMutableFileDataBuffer) async throws -> FSReadFileResult
```

## Parameters

`item`

The item from which to read. FSKit guarantees this item will be of type [`FSItem.ItemType.file`](/documentation/FSKit/FSItem/ItemType/file).

`offset`

The offset in the file from which to start reading.

`length`

The number of bytes to read.

`buffer`

A buffer to receive the bytes read from the file.

`reply`

A block or closure to indicate success or failure. If reading succeeds, pass an instance of [`FSReadFileResult`](/documentation/FSKit/FSReadFileResult) containing the number of bytes read and the updated [`FSItem.Attributes`](/documentation/FSKit/FSItem/Attributes) of the file, along with a `nil` error. If reading fails, pass the relevant error as the second parameter; FSKit ignores the [`FSReadFileResult`](/documentation/FSKit/FSReadFileResult) instance in this case. For an `async` Swift implementation, there’s no reply handler; simply return the result instance or throw an error.

## Discussion

If the number of bytes requested exceeds the number of bytes available before the end of the file, then the call copies only those bytes to `buffer`.
If `offset` points past the last valid byte of the file, don’t reply with an error but set `actuallyRead` to `0`.

---

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)