VillageSoftware.PathMatcher
1.0.1
See the version list below for details.
dotnet add package VillageSoftware.PathMatcher --version 1.0.1
NuGet\Install-Package VillageSoftware.PathMatcher -Version 1.0.1
<PackageReference Include="VillageSoftware.PathMatcher" Version="1.0.1" />
paket add VillageSoftware.PathMatcher --version 1.0.1
#r "nuget: VillageSoftware.PathMatcher, 1.0.1"
// Install VillageSoftware.PathMatcher as a Cake Addin
#addin nuget:?package=VillageSoftware.PathMatcher&version=1.0.1
// Install VillageSoftware.PathMatcher as a Cake Tool
#tool nuget:?package=VillageSoftware.PathMatcher&version=1.0.1
VillageSoftware.PathMatcher
This is a .Net Standard 1.3 library to do some things that System.IO.Path
doesn't do. Its design goals include being thoroughly tested and easily integrated. We aim to make this a trustworthy library for working with mixed URL and Local-style file paths and in particular, resituating files from a local context into the cloud.
In principle, importing this module should keep you from doing work that's already been done by us in a proven, well-tested way.
Setup
This will be a NuGet package but it's not available yet. To try out PathMatcher, please clone and build the repo in Visual Studio.
Features
PathInfo
class
The PathInfo class is instantiated on a path string and exposes a load of helpful properties and methods. It is needed as the basis of the more complex tools in the library.
Properties:
pathInfo.FileDirectoryOnly
- Exposes the directory (without the file)pathInfo.FileNameOnly
- Exposes the file (without the directory)pathInfo.Chunks
- Exposes the path as a List of chunkspathInfo.Separator
- Exposes what was deemed to be the predominant separator in the pathpathInfo.IsUrl
- Exposes a calculated result of whether the path was a URL
Methods:
GetPathWithFinalSeparatorOnOff(string path, bool showFinalSeparator)
- Ensure that the passed path either has or does not have a trailing separatorPathAfterChunk(string chunk)
andPathBeforeChunk
- Return the reamining section of this path which appears after/before the specified chunk (a.k.a segment)ConformSeparatorTo(char separator)
- Change the separators on this PathInfo object to the specified separator and rebuild all of the PathInfo fields (this is useful for merging together local\
paths and remote/
paths)
Example Usage:
string myPath = @"C:\Users\Coder\Documents\Code\Project\File.cs";
var pathInfo = new PathInfo(myPath);
pathInfo.ConformSeparatorTo('/');
var finalPath = pathInfo.GetPathWithFinalSeparatorOnOff(pathInfo.FilePath, true);
PathMatcher
PathMatcher is a static class with utilites which operate on string paths to do special things.
PathMatcher.Resituate
This merges together two paths with some degree of common ancestry to let you, for example, move a local file into the appropriate path on a remote server:
string localPath = @"C:\Users\Alice\Documents\Codes\OpenSource\Project\README.md";
string destinationPath = @"https://filestore.cloud.example/Alice/";
string newRemotePath = PathMatcher.Resituate(localPath, destinationPath);
-> https://filestore.cloud.example/Alice/Documents/Codes/OpenSource/Project/README.md
See PathMatcherTests for more info.
See also design-notes.md
Contributing
To contribute, please open an issue first, where we'd love to discuss the library with you!
License (MIT)
See License.txt
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New feature to safely add path chunks