# FileSystem

File system utilities.

- Source: [`core/lib/fs/index.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/core/lib/fs/index.ts#L15)
- Type last changed: v2.278.0 · 20 Nov 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const fileSystem = new cdk.FileSystem();
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

file_system = cdk.FileSystem()
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

FileSystem fileSystem = new FileSystem();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var fileSystem = new FileSystem();
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

fileSystem := cdk.NewFileSystem()
```

## Initializer

TypeScript:

```ts
new FileSystem()
```

Python:

```python
FileSystem()
```

Java:

```java
new FileSystem()
```

C# / .NET:

```csharp
new FileSystem()
```

Golang:

```go
NewFileSystem()
```

## Properties

- `tmpdir`: string (static) — The real path of the system temp directory.

## Methods

- `copyDirectory(srcDir: string, destDir: string, options?: CopyOptions, rootDir?: string): void` (static) — Copies an entire directory structure.

  **Parameters**

  - `srcDir` — Source directory.
  - `destDir` — Destination directory.
  - `options` — options.
  - `rootDir` — Root directory to calculate exclusions from.

- `copyDirectoryAtomic(srcDir: string, destDir: string, options?: CopyOptions): void` (static) — Copies an entire directory structure.

  Protects against interruption by copying to a temporary directory first and then renaming the directory into place.
  Both the target directory and the temporary directory will be overwritten if they already exist.

  The temporary directory is deleted if an error occurs.

- `fingerprint(fileOrDirectory: string, options?: FingerprintOptions): string` (static) — Produces fingerprint based on the contents of a single file or an entire directory tree.

  Line endings are converted from CRLF to LF.

  The fingerprint will also include:
  1. An extra string if defined in `options.extra`.
  2. The symlink follow mode value.

  **Parameters**

  - `fileOrDirectory` — The directory or file to fingerprint.
  - `options` — Fingerprinting options.

- `isEmpty(dir: string): boolean` (static) — Checks whether a directory is empty.

  **Parameters**

  - `dir` — The directory to check.

- `mkdtemp(prefix: string): string` (static) — Creates a unique temporary directory in the **system temp directory**.

  **Parameters**

  - `prefix` — A prefix for the directory name.

- `rmrf(dirname: string): void` (static) — Deletes a directory.
