-
Notifications
You must be signed in to change notification settings - Fork 77
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 functionality to convert windows paths (all shapes and sizes) to loc
values
#1942
Conversation
…ng on each different OS filesystem type, including documentation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1942 +/- ##
========================================
Coverage 49% 49%
- Complexity 6206 6248 +42
========================================
Files 662 664 +2
Lines 59446 59464 +18
Branches 8618 8621 +3
========================================
+ Hits 29189 29333 +144
+ Misses 28060 27937 -123
+ Partials 2197 2194 -3 ☔ View full report in Codecov by Sentry. |
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 think this function is not ready. Especially for Windows the cases are not thought out.
We need at least some test that show how the library is supposed to work.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Found the exact code that we are looking for here: https://github.com/frohoff/jdk8u-jdk/blob/master/src/windows/classes/sun/nio/fs/WindowsPathParser.java That's GPL licensed. So these three algorithms (parser and normalize and finally toURI) should be mapped exactly to Rascal to get a very reasonable mapping. That should also guarantee that access of these files via the |
…er to source locations
…absolute file names
…t seem to work but actually do not work outside of Windows systems
loc
values
Rewrote from scratch; worked all the feedback from @DavyLandman into it, I believe. Also I'm focusing only on Windows paths from now on. With the current design we can add support for other Path syntaxes incrementally and in different modules. |
I need a little help on the UNC DOS test however. That I can not debug without a running system. |
At the very least the grammar has to be updated, as But I'm open to having a pair programming session. |
Strange; in my documention people always write |
The DOS Device path section on msdn is quite "good" in the coverage I think. To recap:
is a UNC Network path, pointing towards to a network share named
Are UNC DOS Device paths, offer access to all the local devices. so |
…sallowing . and .. as the first path of a DOS Device UNC path. Also removed normalization test since the parser is not going to normalize anything. Too many ifs and buts that need to be dealt with carefully for all kinds of filesystems.
Right. Thanks. I think I've fixed this for now. Would be great if Microsoft posts RFC's for this kind of stuff. Now I combine reading source code and reading documentation :-) With your help it is becoming a lot better. I removed the normalization tests. All filesystem notation normalization is going to be deferred to another library function, because this is a complex matter. So for now |
Unfortunately |
…rent drive interpretation is not supported. //?/C: becomes the root of the drive C:"
LGTM, thanks for all the effort of getting it right on Windows. |
Rethinking this based on feedback from @DavyLandman ; the current PR splits the responsibility of interpreting Windows file paths into a syntactical and a semantic part. Also it supports all shapes and sizes, including UNC paths, and does not normalize automatically.
file:///
,cwd:///
,cwdrive:///
andunc:///
pathsC:
,C:\
,\
,\\
mapping them to different schemesfile:///C:/Program%20Files
is the result of convertingC:\Program Files\
|cwdrive:///|
refers to the root of the file system of the current working directory. On Windows that would beD:/
orC:/
for example, and on Unix it is always/
. Not useful for unix, but essential to be able to encode the\filename
notations of Windows paths.|unc://<machine>/<share>/<path>|
is mapped from\\<machine>\<share>\<path>
and back, such that UNC paths actually work on Windows systems. This only works on Windows systems. We could have used the empty authority position of|file:///|
, however that provides a false sense of portability that we do not have.|unc:///|
literals work as identifiers on any system, but only for file IO on Windows systems.|unc:///|
paths have the annoying property that machine names are valid only for the local network, so they are just as machine-specific as thefile:///
scheme is.file:///
scheme becausenew File
and friends from the Java SDK implement the UNC scheme natively.Added some tests to this effect, but have to run them on Windows.