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 support for Windows #2

Open
apainintheneck opened this issue Aug 23, 2024 · 3 comments
Open

Add support for Windows #2

apainintheneck opened this issue Aug 23, 2024 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@apainintheneck
Copy link
Owner

Windows file paths can use the forward or back slashes to indicate section. The way this is handled in Python is to convert all of the backslashes to forward slashes and then try to match on that. This approach should work for this library as well since we can just check if the code is running on Windows and then make the necessary substitutions.

Another thing that could be done would be to change the pattern generated by the main globlin library to match either forward or back slashes. I don't really want to do it that way since I don't think adding handling for that to globlin really makes sense right now. The main thing that would change my mind would be performance concerns.

The new https://github.com/ditherwither/platform could be used to find out if the user is on Windows.

@apainintheneck apainintheneck added the enhancement New feature or request label Aug 23, 2024
@apainintheneck
Copy link
Owner Author

I had it backwards. All forwards slashes are converted to backslashes. This is fine but would mean converting the regex as well which is a pain. I wonder if doing the opposite would work here. Both the forward and back slashes are considered path component separators on Windows so as long as I only convert the original path to string to match things everything should be fine, right? It would likely be slower on Windows as a result though.

For reference, this is the os.path.normcase method I'm referring to.

https://github.com/python/cpython/blob/dcc3eaef98cd94d6cb6cb0f44bd1c903d04f33b1/Lib/ntpath.py#L45-L78

@apainintheneck apainintheneck added the help wanted Extra attention is needed label Aug 25, 2024
@apainintheneck
Copy link
Owner Author

I think the main thing is the the globlin_fs.glob_from method would need to get the current platform os and then pass that information into the globlin_fs.collect_files method. After the path is created the backlashes would be converted to forward slashes only on Windows and then the original paths would be returned.

@apainintheneck
Copy link
Owner Author

I don't have a Windows box so I probably won't get to this soon since I won't be able to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant