unArchiveValidator function

String unArchiveValidator(
  1. File file,
  2. Directory dir, [
  3. bool? isWritable,
  4. List<String> extAllows = basicArchiveExtAllows,
])

Performs pre-extraction validation for an archive file.

Returns an empty string if valid, otherwise returns a concatenated error message. Validates: existence of file, file extension against extAllows, and write accessibility of dir.

Implementation

String unArchiveValidator(
  File file,
  Directory dir, [
  bool? isWritable, // isDirWriteable
  List<String> extAllows = basicArchiveExtAllows,
]) {
  final List<String> errors = [];

  if (!file.existsSync()) errors.add('not found. ${file.path}');
  isWritable ??= isDirWritable(dir);
  if (!isWritable) errors.add('not writable dir, ${dir.path}');

  final isAllowType = isAllowArchiveType(file.path, extAllows);
  if (!isAllowType) errors.add('not support type, ${file.path}');

  return errors.join(semicolonDelimiter);
}