From 439e0b48b5159206c2152dd577fb0be4f9ea7bc6 Mon Sep 17 00:00:00 2001 From: xieguigang Date: Wed, 2 Dec 2020 17:02:49 +0800 Subject: [PATCH] how to parse ls output --- Centos/Centos.vbproj | 1 + Centos/Commands/ls.vb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Centos/Commands/ls.vb diff --git a/Centos/Centos.vbproj b/Centos/Centos.vbproj index 1448ea0..72fff7d 100644 --- a/Centos/Centos.vbproj +++ b/Centos/Centos.vbproj @@ -232,6 +232,7 @@ + diff --git a/Centos/Commands/ls.vb b/Centos/Commands/ls.vb new file mode 100644 index 0000000..929f9dd --- /dev/null +++ b/Centos/Commands/ls.vb @@ -0,0 +1,31 @@ +Public Class ls + + Public Property permission As String + Public Property number1 As Integer + Public Property user As String + Public Property group As String + Public Property size As String + Public Property [date] As String + Public Property file As String + Public Property link As String + + Public Overrides Function ToString() As String + Dim fileName As String = If(link.StringEmpty, file, $"{file} -> {link}") + Dim line As String = New String() { + permission, number1, user, group, size, [date], fileName + }.JoinBy(vbTab) + + Return line + End Function + + Public Shared Iterator Function Parse(stdout As String) As IEnumerable(Of ls) + For Each line As String In stdout.LineTokens.Skip(1) + Yield ParseLine(line) + Next + End Function + + Private Shared Function ParseLine(line As String) As ls + + End Function + +End Class