filePrefix method

String? filePrefix()

Extracts the portion of the file name before the first "." -

None/null, if there is no file name; The entire file name if there is no embedded .; The portion of the file name before the first non-beginning .; The entire file name if the file name begins with . and has no other .s within; The portion of the file name before the second . if the file name begins with .

Implementation

String? filePrefix() {
  final value = _posix.basename(_string);
  if (value.isEmpty) {
    return null;
  }
  if (!value.contains(".")) {
    return value;
  }
  if (value.startsWith(".")) {
    final splits = value.split(".");
    if (splits.length == 2) {
      return value;
    } else {
      assert(splits.length > 2);
      return splits[1];
    }
  }
  return value.split(".").first;
}