splitPathAndSelPreferringLiteral function
Async sibling of splitPathAndSel that prefers a literal filesystem path
over selector interpretation (omp's splitPathAndSelPreferringLiteral,
issue #4618): filenames whose tail matches the selector grammar (e.g.
test:1-2, log:raw) are legal on POSIX; without this the strict
splitter peels the tail and read refuses to open the real file. The
literal wins whenever env reports the raw path exists — and also when
the existence check itself fails — so an unreachable literal is never
silently reinterpreted as path + selector.
Implementation
Future<SplitReadPath> splitPathAndSelPreferringLiteral(
String rawPath,
FileSystem env,
) async {
final strict = splitPathAndSel(rawPath);
if (strict.sel == null) return strict;
final probe = await env.exists(rawPath);
// Ok(true) → the literal file exists; keep it.
// Err → ambiguous backend failure; keep the literal (fail-safe).
// Ok(false) → definitive miss; fall back to the strict split.
final literalExists = probe.valueOrNull ?? true;
return literalExists ? SplitReadPath(rawPath) : strict;
}