Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add File::MatchOptions to control Dir.glob's behavior #13550

Merged

Conversation

HertzDevil
Copy link
Contributor

Resolves the Windows part of #13196. Closes #13199.

@straight-shoota
Copy link
Member

straight-shoota commented Jun 6, 2023

I'm wondering if GlobOptions is a good name because there are potential related use cases besides glob. Maybe MatchOptions would be a more open alternative?

The path-based option (currently DotFiles, but also CaseInsensitive from #13510) make sense for File.match? - although re-using the options enum is questionable because the other options are invalid for this use case (File.match? operates purely lexically and does not interact with the actual file system. Side track: It would probably better fit in Path).

Not sure if there could be other use cases with File::Info, or other methods in File/Dir.

src/dir/glob.cr Outdated Show resolved Hide resolved
@HertzDevil
Copy link
Contributor Author

Why would DotFiles affect File.match?? Do you mean * can be configured not to match dotfiles there?

@straight-shoota
Copy link
Member

Do you mean * can be configured not to match dotfiles there?

Yes, that was my idea. However, I don't know if that would be much useful for anything.

So we're probably fine to go ahead with this name.

@HertzDevil
Copy link
Contributor Author

HertzDevil commented Jun 15, 2023

It turns out Ruby does support that too (File::FNM_DOTMATCH for File.fnmatch). However I am not sure if the two hidden options make sense for File.match? because that method never touches the filesystem

@straight-shoota straight-shoota added this to the 1.9.0 milestone Jun 20, 2023
@straight-shoota straight-shoota merged commit df960cf into crystal-lang:master Jun 21, 2023
@HertzDevil HertzDevil deleted the feature/dir-glob-match-options branch June 23, 2023 10:45
@straight-shoota straight-shoota changed the title Add Dir::GlobOptions to control Dir.glob's behavior Add File::MatchOptions to control Dir.glob's behavior Jul 5, 2023
Blacksmoke16 pushed a commit to Blacksmoke16/crystal that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:files
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants