-
Notifications
You must be signed in to change notification settings - Fork 6
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 split_windows_volume_prefix()
function and tests.
#7
base: main
Are you sure you want to change the base?
Conversation
test/filepath_test.gleam
Outdated
"HKLM:", | ||
"SOFTWARE/Microsoft/Windows/CurrentVersion", | ||
)), | ||
#("//./Volume{b75e2c83-0000-0000-0000-602f00000000}/Test/Foo.txt", #( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanna say I really personally find what gleam format
did with these nested tuples a bit less readable that the original version...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
What's the motivation for this addition? I've not come across a function like this before- what are some scenarios in which I would use it?
It's generally useful to be able to split the drive of a path you're dealing with on Windows for a variety of reasons like determining if it's a local drive, remote UNC path, registry hive path, etc..., or processing/reusing later if it's a UNC share (like extracting the hostname/IP from it). Python's stdlib has one FWIW: https://docs.python.org/3/library/os.path.html#os.path.splitdrive Even if you don't want to have this function be public, it's still useful as an internal function to be reused in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Thank you. I've left some notes inline
266b537
to
d599b27
Compare
@lpil changes done, I've even squashed the commit into one (minus the version bump and changelog update which is still a separate commit) Thanks for you patience, and please re-review at your leisure! PS: considering it's important to test with both |
This patch adds a new public function for splitting Windows paths into its volume prefix and rest of the path.
d599b27
to
248ed76
Compare
@lpil just pushed the latest iteration on it with the added edge case you suggested. Note that after more consideration of This will allow the later update of |
Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
Hey there @lpil, glad to have some time for Gleaming again. Following the Erlang pattern matching fix reaching GA in Gleam 1.2, I have went ahead an updated this PR, PTAL whenever you can! 😄 |
WARN: this code may NOT run correctly on OTP because of this compiler bug: gleam-lang/gleam#2733