Skip to content
v2.275.0

FileSystem Class ​

File system utilities.

Example ​

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
# 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
// 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();
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();
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 ​

ts
new FileSystem()
python
FileSystem()
java
new FileSystem()
csharp
new FileSystem()
go
NewFileSystem()

Properties ​

tmpdirstringtmpdirstrtmpdirStringTmpdirstringTmpdir*stringstatic#
The real path of the system temp directory.

Methods ​

copyDirectory(srcDir: string, destDir: string, options?: CopyOptions, rootDir?: string): void@staticmethod def copy_directory(src_dir: str, dest_dir: str, options: typing.Optional[CopyOptions] = None, root_dir: typing.Optional[str] = None) -> Nonepublic static void copyDirectory(String srcDir, String destDir, CopyOptions options, String rootDir)public static void CopyDirectory(string srcDir, string destDir, CopyOptions? options = null, string? rootDir = null)func CopyDirectory(SrcDir *string, DestDir *string, Options CopyOptions, RootDir *string)static#
Copies an entire directory structure.
4 parameters

Parameters

  • srcDirsrc_dirsrcDirsrcDirSrcDir — Source directory.
  • destDirdest_dirdestDirdestDirDestDir — Destination directory.
  • optionsoptionsoptionsoptionsOptions — options.
  • rootDirroot_dirrootDirrootDirRootDir — Root directory to calculate exclusions from.
fingerprint(fileOrDirectory: string, options?: FingerprintOptions): string@staticmethod def fingerprint(file_or_directory: str, options: typing.Optional[FingerprintOptions] = None) -> strpublic static String fingerprint(String fileOrDirectory, FingerprintOptions options)public static string Fingerprint(string fileOrDirectory, FingerprintOptions? options = null)func Fingerprint(FileOrDirectory *string, Options FingerprintOptions) *stringstatic#
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.
2 parameters

Parameters

  • fileOrDirectoryfile_or_directoryfileOrDirectoryfileOrDirectoryFileOrDirectory — The directory or file to fingerprint.
  • optionsoptionsoptionsoptionsOptions — Fingerprinting options.
isEmpty(dir: string): boolean@staticmethod def is_empty(dir: str) -> boolpublic static Boolean isEmpty(String dir)public static bool IsEmpty(string dir)func IsEmpty(Dir *string) *boolstatic#
Checks whether a directory is empty.
1 parameter

Parameters

  • dirdirdirdirDir — The directory to check.
mkdtemp(prefix: string): string@staticmethod def mkdtemp(prefix: str) -> strpublic static String mkdtemp(String prefix)public static string Mkdtemp(string prefix)func Mkdtemp(Prefix *string) *stringstatic#
Creates a unique temporary directory in the **system temp directory**.
1 parameter

Parameters

  • prefixprefixprefixprefixPrefix — A prefix for the directory name.
rmrf(dirname: string): void@staticmethod def rmrf(dirname: str) -> Nonepublic static void rmrf(String dirname)public static void Rmrf(string dirname)func Rmrf(Dirname *string)static#
Deletes a directory.