# Struct `kurogane::capability::FilesystemBuilder`

```rust
pub struct FilesystemBuilder { /* private fields */ }
```

Builder for [`Filesystem`].

[`Filesystem`]: https://kurogane-rs.org/docs/api/capabilities/filesystem.md

## Methods

### `allow_hard_links`

```rust
pub fn allow_hard_links(&mut self, allow: bool) -> &mut Self
```

Permits regular files that have other names (hard links). By default
such a file is refused (`PATH_DENIED`) by every operation that reads,
writes, copies or measures its contents. Its other names may lie
outside every root or under a deny rule and no platform can tell the
location re-check which. Enable only when the roots hold multiply
linked files by design (a pnpm store, a local `git clone`) and nobody
untrusted can create links in them. Listing, removing and renaming a
link's name are unaffected either way.

### `max_file_size`

```rust
pub fn max_file_size(&mut self, bytes: u64) -> &mut Self
```

Caps the bytes `read_file` returns and `write_file` accepts
([`FsError::TooLarge`] beyond it). A whole file travels in one IPC
message and is held in memory by both processes. The cap bounds what
one renderer call can cost until file transfers stream.
Defaults to [`Filesystem::DEFAULT_MAX_FILE_SIZE`]. `copy_file`
stays in the browser process and is not capped.

[`Filesystem::DEFAULT_MAX_FILE_SIZE`]: https://kurogane-rs.org/docs/api/capabilities/filesystem.md#associatedconstant.DEFAULT_MAX_FILE_SIZE
[`FsError::TooLarge`]: https://kurogane-rs.org/docs/api/capabilities/fserror.md#variant.TooLarge

### `scope`

```rust
pub fn scope(
    &mut self,
    name: impl Into<String>,
    declare: impl FnOnce(&mut ScopeBuilder),
) -> ScopeId
```

Declares a scope and returns its handle. `name` labels configuration
errors only.

### `grant`

```rust
pub fn grant(
    &mut self,
    origin: Origin,
    scope: ScopeId,
    access: FsAccess,
) -> &mut Self
```

Grants `access` over `scope` to `origin`, matched exactly. Several
grants to one origin combine.

### `build`

```rust
pub fn build(self) -> Result<Filesystem, FsConfigError>
```

Opens every allow root and checks every rule.

#### Errors

Returns [`FsConfigError`] for a scope handle from another builder, a
grant to the opaque origin, a malformed deny glob, a deny path outside
its scope's roots, or an allow root that cannot be opened as a
directory (including every root on platforms without a safe-open
backend).

[`FsConfigError`]: https://kurogane-rs.org/docs/api/capabilities/fsconfigerror.md

## Trait implementations

- `impl Default for FilesystemBuilder`

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/capability/authorized.rs#L77
