---
title: "write(from:startingAt:length:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsblockdeviceresource/write(from:startingat:length:)-2fmgt"
---

# write(from:startingAt:length:)

Synchronously writes data from from a buffer to the resource and executes a block afterwards.

## Declaration

```swift
func write(from buffer: UnsafeRawBufferPointer, startingAt offset: off_t, length: Int) throws -> Int
```

## Parameters

- `buffer`: A buffer to provide the data.
- `offset`: The offset into the resource from which to start writing.
- `length`: A maximum number of bytes to write. The completion handler receives a parameter with the actual number of bytes write.

## Return Value

Return Value The actual number of bytes written.

## Discussion

Discussion This method is a synchronous version of writeFrom:startingAt:length:completionHandler:. In some cases, this method performs a partial write. In this case, the return value is shorter than the requested length, and the error is set to nil. note: Any error encountered while writing data.

## See Also

### Reading and writing data

- [read(into:startingAt:length:)](fskit/fsblockdeviceresource/read(into:startingat:length:)-4ax6s.md)
- [read(into:startingAt:length:)](fskit/fsblockdeviceresource/read(into:startingat:length:)-5yozi.md)
- [read(into:startingAt:length:completionHandler:)](fskit/fsblockdeviceresource/read(into:startingat:length:completionhandler:).md)
- [write(from:startingAt:length:)](fskit/fsblockdeviceresource/write(from:startingat:length:)-9oa1x.md)
- [write(from:startingAt:length:completionHandler:)](fskit/fsblockdeviceresource/write(from:startingat:length:completionhandler:).md)
