libglob: allow "." and ".." to be matched

... also don't read the whole directory if the glob for that path
component doesn't contain any metacharacters.

Patterns like `../*.jpg` will work now, and `.*` will match both `.` and
`..` to be consistent with shell expansion.

As before: Just `*` still won't match `.` and `..`, while it will still
match dotfiles like `.git` by default.
libglob: only return dirs for globs ending in /

`foo.txt/` should not return `foo.txt` if `foo.txt` is in fact a text
file and not a directory.
auto merge of #13383 : ben0x539/rust/glob-dots, r=brson

Fixes #12930.