> ## Documentation Index
> Fetch the complete documentation index at: https://docs.resq.software/llms.txt
> Use this file to discover all available pages before exploring further.

# Resq FileHandle

## FileHandle

```cpp theme={null}
#include <file_utils.hpp>
```

RAII file handle that ensures closure.

Example:

```cpp theme={null}
{
    auto file = [FileHandle::open](#open)("data.txt", std::ios::out);
    if (file.is_open()) {
        file.stream() << "Hello, World!\n";
    }
}  // File automatically closed here
```

### Public Methods

| Return           | Name                          | Description            |
| ---------------- | ----------------------------- | ---------------------- |
|                  | [`FileHandle`](#filehandle-1) | Defaulted constructor. |
|                  | [`FileHandle`](#filehandle-2) | Deleted constructor.   |
|                  | [`FileHandle`](#filehandle-3) |                        |
| `bool`           | [`is_open`](#is_open) `const` |                        |
| `std::fstream &` | [`stream`](#stream)           |                        |

***

#### FileHandle

```cpp theme={null}
FileHandle() = default
```

Defaulted constructor.

***

#### FileHandle

```cpp theme={null}
FileHandle(const FileHandle &) = delete
```

Deleted constructor.

***

#### FileHandle

`inline`

```cpp theme={null}
inline FileHandle(FileHandle && other) noexcept
```

***

#### is\_open

`const`

```cpp theme={null}
inline bool is_open() const
```

***

#### stream

`inline`

```cpp theme={null}
inline std::fstream & stream()
```

### Public Static Methods

| Return       | Name                     | Description |
| ------------ | ------------------------ | ----------- |
| `FileHandle` | [`open`](#open) `static` |             |

***

#### open

`static`

```cpp theme={null}
static inline FileHandle open(const std::string & path, std::ios::openmode mode)
```

### Private Attributes

| Return         | Name                  | Description |
| -------------- | --------------------- | ----------- |
| `std::fstream` | [`stream_`](#stream_) |             |

***

#### stream\_

```cpp theme={null}
std::fstream stream_
```
