filePrefix method
Extracts the portion of the file name before the first "." -
None, 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
Option<String> filePrefix() {
final value = _posix.basename(string);
if (value.isEmpty) {
return None;
}
if (!value.contains(".")) {
return Some(value);
}
if (value.startsWith(".")) {
final splits = value.split(".");
if (splits.length == 2) {
return Some(value);
} else {
assert(splits.length > 2);
return Some(splits[1]);
}
}
return Some(value.split(".").first);
}