Skip to content

FileSystem

File system utilities.

Initializers

import ros_cdk_core
ros_cdk_core.FileSystem()
Name Type Description

Static Functions

Name Description
copy_directory Copies an entire directory structure.
fingerprint Produces fingerprint based on the contents of a single file or an entire directory tree.
is_empty Checks whether a directory is empty.
mkdtemp Creates a unique temporary directory in the system temp directory.

copy_directory

import ros_cdk_core
ros_cdk_core.FileSystem.copy_directory(
  src_dir: str,
  dest_dir: str,
  exclude: typing.List[str] = None,
  follow: SymlinkFollowMode = None,
  ignore_mode: IgnoreMode = None,
  root_dir: str = None
)

Copies an entire directory structure.

src_dirRequired

  • Type: str

Source directory.


dest_dirRequired

  • Type: str

Destination directory.


excludeOptional

  • Type: typing.List[str]
  • Default: nothing is excluded

File paths matching the patterns will be excluded.

See ignoreMode to set the matching behavior. Has no effect on Assets bundled using the bundling property.


followOptional

A strategy for how to handle symlinks.


ignore_modeOptional

The ignore behavior to use for exclude patterns.


root_dirOptional

  • Type: str

Root directory to calculate exclusions from.


fingerprint

import ros_cdk_core
ros_cdk_core.FileSystem.fingerprint(
  file_or_directory: str,
  exclude: typing.List[str] = None,
  follow: SymlinkFollowMode = None,
  ignore_mode: IgnoreMode = None,
  extra_hash: str = None
)

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.

file_or_directoryRequired

  • Type: str

The directory or file to fingerprint.


excludeOptional

  • Type: typing.List[str]
  • Default: nothing is excluded

File paths matching the patterns will be excluded.

See ignoreMode to set the matching behavior. Has no effect on Assets bundled using the bundling property.


followOptional

A strategy for how to handle symlinks.


ignore_modeOptional

The ignore behavior to use for exclude patterns.


extra_hashOptional

  • Type: str
  • Default: hash is only based on source content

Extra information to encode into the fingerprint (e.g. build instructions and other inputs).


is_empty

import ros_cdk_core
ros_cdk_core.FileSystem.is_empty(
  dir: str
)

Checks whether a directory is empty.

dirRequired

  • Type: str

The directory to check.


mkdtemp

import ros_cdk_core
ros_cdk_core.FileSystem.mkdtemp(
  prefix: str
)

Creates a unique temporary directory in the system temp directory.

prefixRequired

  • Type: str

A prefix for the directory name.

Six random characters will be generated and appended behind this prefix.


Properties

Name Type Description
tmpdir str The real path of the system temp directory.

tmpdirRequired

tmpdir: str
  • Type: str

The real path of the system temp directory.