FileSystem Class
File system utilities.
| Source | core/lib/fs/index.ts |
|---|---|
| Type last changed |
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
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.
copyDirectoryAtomic(srcDir: string, destDir: string, options?: CopyOptions): void@staticmethod def copy_directory_atomic(src_dir: str, dest_dir: str, options: typing.Optional[CopyOptions] = None) -> Nonepublic static void copyDirectoryAtomic(String srcDir, String destDir, CopyOptions options)public static void CopyDirectoryAtomic(string srcDir, string destDir, CopyOptions? options = null)func CopyDirectoryAtomic(SrcDir *string, DestDir *string, Options CopyOptions) static #Copies an entire directory structure.
notes
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@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) *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:
- An extra string if defined in
options.extra. - 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) *bool static #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) *string static #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.