makeReadOnly function
Makes a file read-only by changing its permissions to 444.
Returns true
if the file was successfully made read-only,
otherwise returns false
.
Implementation
bool makeReadOnly(String filePath) {
try {
final result = Process.runSync('chmod', ['444', filePath]);
if (result.exitCode == 0) {
return true;
} else {
print('Failed to make file read-only: ${result.stderr}');
return false;
}
} catch (e) {
print('Error making file read-only: $e');
return false;
}
}