| 1 | #Region "Microsoft.VisualBasic::f10a0251981bece9e687588eec59423b, Microsoft.VisualBasic.Core\Language\Language\UnixBash\ShellSyntax.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 ShellSyntax |
| 35 | ' |
| 36 | ' Properties: f, l, ls, lsDIR, r |
| 37 | ' rf, rm |
| 38 | ' |
| 39 | ' Function: DIRHandle, wildcards |
| 40 | ' |
| 41 | ' |
| 42 | ' /********************************************************************************/ |
| 43 | |
| 44 | #End Region |
| 45 | |
| 46 | Imports Microsoft.VisualBasic.Language.UnixBash.FileSystem |
| 47 | |
| 48 | Namespace Language.UnixBash |
| 49 | |
| 50 | ''' <summary> |
| 51 | ''' VB.NET language shell syntax supports exports |
| 52 | ''' </summary> |
| 53 | Public Module ShellSyntax |
| 54 | |
| 55 | #Region "ls -l /*" |
| 56 | ''' <summary> |
| 57 | ''' ``ls -l -ext("*.xml") <= DIR``, The filesystem search proxy |
| 58 | ''' </summary> |
| 59 | ''' <returns></returns> |
| 60 | Public ReadOnly Property ls As New Search |
| 61 | ''' <summary> |
| 62 | ''' Long name(DIR+fiename), if not only file name. |
| 63 | ''' </summary> |
| 64 | ''' <returns></returns> |
| 65 | Public ReadOnly Property l As New SearchOpt(SearchOpt.Options.LongName) |
| 66 | ''' <summary> |
| 67 | ''' 递归的搜索 |
| 68 | ''' </summary> |
| 69 | ''' <returns></returns> |
| 70 | Public ReadOnly Property r As New SearchOpt(SearchOpt.Options.Recursive) |
| 71 | ''' <summary> |
| 72 | ''' Searching the directory, if this parameter is not presents, then returns search file. |
| 73 | ''' </summary> |
| 74 | ''' <returns></returns> |
| 75 | Public ReadOnly Property lsDIR As New SearchOpt(SearchOpt.Options.Directory) |
| 76 | |
| 77 | ''' <summary> |
| 78 | ''' 可以使用这个来限定文件或者文件夹对象的搜索范围 |
| 79 | ''' </summary> |
| 80 | ''' <param name="__wildcards">可以为文件拓展或者对文件名的通配符的表达式,假若这个是空的,则会默认搜索所有文件*.*</param> |
| 81 | ''' <returns></returns> |
| 82 | Public Function wildcards(ParamArray __wildcards As String()) As SearchOpt |
| 83 | Dim opt As New SearchOpt(SearchOpt.Options.Ext) |
| 84 | |
| 85 | If __wildcards.IsNullOrEmpty Then |
| 86 | __wildcards = {"*.*"} |
| 87 | End If |
| 88 | |
| 89 | For Each s As String In __wildcards |
| 90 | Call opt.wildcards.Add(s) |
| 91 | Next |
| 92 | |
| 93 | Return opt |
| 94 | End Function |
| 95 | |
| 96 | Public Function DIRHandle(res As String) As Integer |
| 97 | Return FileHandles.OpenHandle(res) |
| 98 | End Function |
| 99 | #End Region |
| 100 | |
| 101 | #Region "rm -rf /*" |
| 102 | |
| 103 | Public ReadOnly Property rm As FileDelete |
| 104 | Get |
| 105 | Return New FileDelete |
| 106 | End Get |
| 107 | End Property |
| 108 | |
| 109 | Public ReadOnly Property rf As rmOption |
| 110 | Public ReadOnly Property f As rmOption |
| 111 | #End Region |
| 112 | |
| 113 | End Module |
| 114 | End Namespace |