-
Notifications
You must be signed in to change notification settings - Fork 10
Description
This is a continuation of my previous issue #15 - I wanted to keep the two items seperate because technically they are different issues.
If I provide (2) paths to IPurePath.Join() such as:
c:\someOther\directoryName\\someFileName.exe
var path = new MockPath(@"c:\ProgramFiles\");
var joined = path.Join(@"c:\someOther\directoryName\",@"\someFile.exe");
// I can also provide these arguments and the same results as below will occur:
var joined = path.Join(@"c:\someOther\directoryName",@"\someFile.exe");Exepected Result
Option 1: Be smart
Note: This might have some issues with Unix systems and might not be a viable option. See Option 2 and 3.
-
Be smart and use the first rooted and (fully qualified) absolute path, then merge that with the rooted (relative) path | (This is for
IPurePath) -
c:\someOther\directoryName\someFile.exe
joined.ToString() == @"c:\someOther\directoryName\someFile.exe";Option 2: Be safe
^^ This gets a bit tricky with Unix Systems, so perhaps we throw an exception if (2) rooted paths are provided which are both fully qualified due to unix path formats it cannot be determined which is the relative path?
- If two rooted paths are provided, we throw an exception | (This is for
IPurePath)
Option 3: Be safe, and almost smart
- If two rooted paths are provided, we throw an exception | (This is for
IPurePath) - If two rooted paths are provided, but one of them has a 'drive' path (windows), we use that as the 'base fully qualified absolute path, then merge the other paths with it. | (This is for
IPurePath)
Actual Result
The result will return c:\someFileName.exe
joined.ToString() == @"c:\someFile.exe";My vote is for Option 3 as the method already tries to 'be smart' by appending the c: to the \someFileName.exe and makes that decision on its own.
Would love to know your thoughts! IMO we should be as cross platform friendly (safe) as possible
