| 1 | #Region "Microsoft.VisualBasic::1b9aad55631216c0693df3837adeb35e, Microsoft.VisualBasic.Core\Extensions\IO\Path\Extensions.vb" |
| 2 | |
| 3 | ' Author: |
| 4 | ' |
| 5 | ' asuka (amethyst.asuka@gcmodeller.org) |
| 6 | ' xie (genetics@smrucc.org) |
| 7 | ' xieguigang (xie.guigang@live.com) |
| 8 | ' |
| 9 | ' Copyright (c) 2018 GPL3 Licensed |
| 10 | ' |
| 11 | ' |
| 12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
| 13 | ' |
| 14 | ' |
| 15 | ' This program is free software: you can redistribute it and/or modify |
| 16 | ' it under the terms of the GNU General Public License as published by |
| 17 | ' the Free Software Foundation, either version 3 of the License, or |
| 18 | ' (at your option) any later version. |
| 19 | ' |
| 20 | ' This program is distributed in the hope that it will be useful, |
| 21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | ' GNU General Public License for more details. |
| 24 | ' |
| 25 | ' You should have received a copy of the GNU General Public License |
| 26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | |
| 28 | |
| 29 | |
| 30 | ' /********************************************************************************/ |
| 31 | |
| 32 | ' Summaries: |
| 33 | |
| 34 | ' Module Extensions |
| 35 | ' |
| 36 | ' Function: Combine, GetFullPath, Pairs |
| 37 | ' |
| 38 | ' |
| 39 | ' /********************************************************************************/ |
| 40 | |
| 41 | #End Region |
| 42 | |
| 43 | Imports System.Runtime.CompilerServices |
| 44 | Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel |
| 45 | Imports IOModule = System.IO.Path |
| 46 | |
| 47 | Namespace FileIO.Path |
| 48 | |
| 49 | Public Module Extensions |
| 50 | |
| 51 | Public Iterator Function Pairs(ParamArray paths As NamedValue(Of String())()) As IEnumerable(Of Dictionary(Of String, String)) |
| 52 | Dim primary As NamedValue(Of String()) = paths(Scan0) |
| 53 | Dim others = (From path As NamedValue(Of String()) |
| 54 | In paths.Skip(1) |
| 55 | Select path.Name, |
| 56 | pls = (From p As String |
| 57 | In path.Value |
| 58 | Select pName = p.BaseName, |
| 59 | p).ToArray).ToArray |
| 60 | |
| 61 | For Each path As String In primary.Value |
| 62 | Dim q As String = path.BaseName |
| 63 | Dim result As New Dictionary(Of String, String) From {{primary.Name, path}} |
| 64 | |
| 65 | For Each otherpath In others |
| 66 | For Each S In otherpath.pls |
| 67 | If InStr(q, S.pName, CompareMethod.Text) = 1 OrElse |
| 68 | InStr(S.pName, q, CompareMethod.Text) = 1 Then |
| 69 | |
| 70 | result.Add(otherpath.Name, S.p) |
| 71 | Exit For |
| 72 | End If |
| 73 | Next |
| 74 | Next |
| 75 | |
| 76 | If result.Count = paths.Length Then |
| 77 | Yield result |
| 78 | End If |
| 79 | Next |
| 80 | End Function |
| 81 | |
| 82 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
| 83 | Public Function GetFullPath(relativePath As String) As String |
| 84 | Return IOModule.GetFullPath(relativePath) |
| 85 | End Function |
| 86 | |
| 87 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
| 88 | Public Function Combine(destination$, name$) As String |
| 89 | Return IOModule.Combine(destination, name) |
| 90 | End Function |
| 91 | End Module |
| 92 | End Namespace |