requireCMakeFile function

Directory requireCMakeFile(
  1. String dirPath
)

Checks if the given directory contains 'native_splash_screen.cmake'. If the file exists, returns the Directory object. Otherwise, logs an error and exits the process.

Implementation

Directory requireCMakeFile(String dirPath) {
  // Normalize the path to remove any trailing slashes
  final normalizedPath = dirPath.replaceAll(RegExp(r'[/\\]+$'), '');

  final cmakeFilePath = '$normalizedPath/native_splash_screen.cmake';
  final cmakeFile = File(cmakeFilePath);

  if (cmakeFile.existsSync()) {
    return Directory(dirPath);
  } else {
    throw FileSystemException();
  }
}