enumerateFileSystemInfos method

  1. @override
Iterable<FileSystemInfoBase> enumerateFileSystemInfos()
override

Enumerates all files and directories in the directory.

Implementation

@override
Iterable<FileSystemInfoBase> enumerateFileSystemInfos() {
  var items = <FileSystemInfoBase>[];
  if (_directoryInfo.existsSync()) {
    var fileSystemInfos = <FileSystemEntity>[];
    try {
      fileSystemInfos.addAll(_directoryInfo.listSync(recursive: false));
    } on Exception {
      // Ignore exceptions when listing directory contents
    }

    for (var fileInfo in fileSystemInfos) {
      if (fileInfo is Directory) {
        items.add(DirectoryInfoWrapper(fileInfo));
      } else if (fileInfo is File) {
        items.add(FileInfoWrapper(fileInfo));
      }
    }
  }
  return items;
}