getLogIndex method

int getLogIndex(
  1. String filePath
)

Gets log index from a file path.

Implementation

int getLogIndex(String filePath) {
  if (isLogFile(filePath)) {
    return _fileRegExp.allMatches(filePath).map((match) {
      if (match.groupCount > 0) {
        final parseGroup = match.group(1);
        if (parseGroup != null) {
          return int.parse(parseGroup);
        }
      }
      return -1;
    }).firstWhere((i) => i != -1, orElse: () => -1);
  } else {
    return -1;
  }
}