makeFile static method

File makeFile(
  1. Directory base, {
  2. String? file,
  3. String? ext,
  4. String? dir,
})

Implementation

static File makeFile(Directory base, {String? file, String? ext, String? dir}) {
  String s = file ?? uuidString();
  if (notBlank(ext)) {
    if (ext!.startsWith(".")) {
      s = s + ext;
    } else {
      s = "$s.$ext";
    }
  }
  if (dir == null || dir.isEmpty) {
    return File(joinPath(base.path, s));
  }
  Directory subdir = Directory(joinPath(base.path, dir));
  if (!subdir.existsSync()) {
    subdir.createSync(recursive: true);
  }
  return File(joinPath(subdir.path, s));
}