-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandDealer.cls
More file actions
91 lines (79 loc) · 2.69 KB
/
CommandDealer.cls
File metadata and controls
91 lines (79 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CommandDealer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private Commands()
Private Sub Class_Initialize()
Commands = Array("version", "help", "ls", "touch", "cd")
End Sub
Public Function GetCommands(Optional ParamCount As Integer = -1) As String
Dim Output As String
Dim Index As Integer
For Index = 0 To UBound(Commands)
Output = Output & Commands(Index) & vbCrLf
Next Index
GetCommands = Output
End Function
Public Function GetVersionDescription() As String
GetVersionDescription = App.EXEName & " [ Version " & App.Major & "." & App.Minor & "." & App.Revision & " ]" & vbCrLf & App.LegalCopyright & vbCrLf
End Function
Public Function Deal() As String
Dim Cmds
Dim CurrentPath As String
If CurInput = Empty Then Exit Function
Cmds = Split(CurInput, " ")
Cmds(0) = LCase(Cmds(0))
Dim Index As Integer
For Index = 0 To UBound(Commands)
If Commands(Index) = Cmds(0) Then Exit For
Next Index
If Index > UBound(Commands) Then
Deal = "Can't Find Command """ & Cmds(0) & """" & vbCrLf
End If
CurrentPath = Left(CurPath, Len(CurPath) - 2)
Select Case Cmds(0)
Case Commands(0)
Deal = GetVersionDescription()
Case Commands(1)
Deal = GetCommands()
Case Commands(2)
Mainfrm.CurPathCom.Refresh
For Index = 0 To Mainfrm.CurPathCom.ListCount - 1
Deal = Deal & Mainfrm.CurPathCom.List(Index) & vbCrLf
Next Index
Case Commands(3)
If UBound(Cmds) < 1 Then
Deal = "Error: No File Name" & vbCrLf
Else
Open CurrentPath & Cmds(1) For Output As #1
Close
End If
Case Commands(4)
If UBound(Cmds) < 1 Then
Deal = "Error: No Path" & vbCrLf
Else
If Cmds(1) = ".." Then
CurPath = LastDirectory()
ElseIf Cmds(1) = "." Then
Else
If Dir(Cmds(1), vbDirectory) = "" Then
Deal = "Error: Path """ & Cmds(1) & """ does not exists" & vbCrLf
Else
CurPath = Cmds(1) & IIf(Right(Cmds(1), 1) = "\", Empty, "\") & "> "
End If
End If
End If
If Left(Deal, 5) <> "Error" Then Mainfrm.CurPathCom.Path = Left(CurPath, Len(CurPath) - 2)
End Select
Deal = vbCrLf & Deal
End Function