---
title: "closeItem(_:modes:context:replyHandler:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsvolume/openclosehandler/closeitem(_:modes:context:replyhandler:)"
---

# closeItem(_:modes:context:replyHandler:)

Closes a file from further access.

## Declaration

```swift
func closeItem(_ item: FSItem, modes: FSVolume.OpenModes, context: FSContext, replyHandler reply: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func closeItem(_ item: FSItem, modes: FSVolume.OpenModes, context: FSContext) async throws
```

## Parameters

- `item`: The item to close.
- `modes`: The set of mode flags to keep after this close.
- `context`: An object that enables context-aware file system decisions throughout the operation.
- `reply`: A block or closure to indicate success or failure. If closing fails, pass an error as the one parameter to the reply handler. If closing succeeds, pass nil. For an async Swift implementation, there’s no reply handler; simply throw an error or return normally.

## See Also

### Opening and closing

- [openItem(_:modes:context:replyHandler:)](fskit/fsvolume/openclosehandler/openitem(_:modes:context:replyhandler:).md)
- [FSVolume.OpenModes](fskit/fsvolume/openmodes.md)
- [FSContext](fskit/fscontext.md)
