-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to resolve with path.Parser
Right now path.Resolve() takes UNIX style paths. In order to add Windows pathanme support, one approach would be to have path.ResolveUNIX() and path.ResolveWindows(). But this is not sufficient, because during a single resolution pass we could encounter both kinds of paths. We solve this by wrapping pathname strings in a path.Parser. This allows path.Resolve() to remain a generic resolution algorithm that is oblivious of the path that is being resolved.
- Loading branch information
1 parent
46320cc
commit d8bd9aa
Showing
12 changed files
with
239 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package path | ||
|
||
// Parser is used by Resolve to parse paths in the resolution. Implementations | ||
// of ParseScope() should return a new copy of Parser and leave the current | ||
// instance unmodified. It is permitted to call ParseScope() multiple times. | ||
type Parser interface { | ||
ParseScope(scopeWalker ScopeWalker) (next ComponentWalker, remainder RelativeParser, err error) | ||
} | ||
|
||
// RelativeParser is used by Resolve to parse relative paths in the resolution. | ||
// Implementations of ParseFirstComponent() should return a new copy of Parser | ||
// and leave the current instance unmodified. It is permitted to call | ||
// ParseFirstComponent() multiple times. | ||
type RelativeParser interface { | ||
ParseFirstComponent(componentWalker ComponentWalker, mustBeDirectory bool) (next GotDirectoryOrSymlink, remainder RelativeParser, err error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.