makeFilenameUniqueSync method

File makeFilenameUniqueSync({
  1. Context? pathContext,
})

Synchronously changes only the name of this file to a new unique name that does not already exist in parent.

Implementation

File makeFilenameUniqueSync({
  lib_path.Context? pathContext,
}) {
  pathContext ??= lib_path.context;

  final names = get_unique_file_impl.getNamesInDirSync(
    directory: parent,
    pathContext: pathContext,
  );
  final uniqueName = get_unique_file_impl.getUniqueFilename(
    namesInDir: names,
    currentDir: parent,
  );

  return changeFilenameSync(uniqueName, pathContext: pathContext);
}