allows method

  1. @override
bool allows(
  1. dynamic operation
)
override

Checks if this permission allows the given operation.

Implementation

@override
bool allows(dynamic operation) {
  if (operation is! Map<String, dynamic>) return false;

  final opType = operation['type'];
  final opPath = operation['path'];

  if (opType != 'filesystem') return false;

  // Check if the operation is allowed
  final requiredRead = operation['read'] ?? false;
  final requiredWrite = operation['write'] ?? false;
  final requiredExecute = operation['execute'] ?? false;

  if ((requiredRead && !_read) ||
      (requiredWrite && !_write) ||
      (requiredExecute && !_execute)) {
    return false;
  }

  // Check path restrictions
  if (_path != null && opPath != null) {
    // Simple path prefix check (could be made more sophisticated)
    if (!opPath.startsWith(_path)) {
      return false;
    }
  }

  return true;
}