isExecutable function
Returns whether path
is considered an executable file on this OS.
May optionally define how to implement getStat
or whether to execute based
on whether this is the windows platform (isWindows
) - if not set it is
automatically extracted from dart:io#Platform
.
NOTE: On windows this always returns true
.
Implementation
FutureOr<bool> isExecutable(
String path, {
bool? isWindows,
FutureOr<FileStat> Function(String path) getStat = FileStat.stat,
}) {
// Windows has no concept of executable.
if (isWindows ?? Platform.isWindows) return true;
final stat = getStat(path);
if (stat is FileStat) {
return _isExecutable(stat);
}
return stat.then(_isExecutable);
}