getUniqueFilenameSync method
Get a new random and unique filename in this Directory.
-
length
- The length of the unique filename. The total length of the name of the returned file islength + (prefix?.length ?? 0) + (extension?.length ?? 0)
. -
maxTries
- How many times a new filename should be generated until a unique one is found in the Directory. If this parameter is set to null, then new filenames will be generated until a unique one is found. If this parameter is set to a fixed number and no unique name can be found, then an OutOfTriesException gets thrown. -
prefix
- The prefix for the unique filename. -
extension
- The file extension.
See also getUniqueFilename
Implementation
String getUniqueFilenameSync({
int length = 30,
int? maxTries,
String? prefix,
String? extension,
lib_path.Context? pathContext,
}) {
pathContext ??= lib_path.context;
final names = get_unique_file_impl.getNamesInDirSync(
directory: this,
pathContext: pathContext,
);
return get_unique_file_impl.getUniqueFilename(
currentDir: this,
length: length,
maxTries: maxTries,
namesInDir: names,
extension: extension,
prefix: prefix,
);
}