2022-11-06 08:20:38 +00:00
|
|
|
|
Module DirectoryManagements
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Dim spaces As String
|
2022-11-06 08:20:38 +00:00
|
|
|
|
Public Sub TerminalDirectories(TheDirectory As String)
|
2022-11-13 08:15:05 +00:00
|
|
|
|
Console.Pseudodir = TheDirectory.Replace(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\ShiftFS", "!")
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine("Contents of " & Console.Pseudodir)
|
|
|
|
|
NewLine(Nothing)
|
|
|
|
|
NewLine("[DIR] 0 KB .")
|
|
|
|
|
NewLine("[DIR] 0 KB ..")
|
2022-11-06 08:20:38 +00:00
|
|
|
|
For Each Dir As String In IO.Directory.GetDirectories(TheDirectory)
|
|
|
|
|
Dim dirinf As New IO.DirectoryInfo(Dir)
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine("[DIR] 0 KB " & dirinf.Name)
|
2022-11-06 08:20:38 +00:00
|
|
|
|
Next
|
2022-11-06 09:22:35 +00:00
|
|
|
|
For Each file As String In IO.Directory.GetFiles(TheDirectory)
|
|
|
|
|
Dim filinf As New IO.FileInfo(file)
|
|
|
|
|
Dim filsize As Long = filinf.Length / 1024
|
|
|
|
|
Dim thesize As Integer = 1
|
|
|
|
|
Do
|
|
|
|
|
If filsize >= 1024 Then
|
|
|
|
|
filsize = filsize / 1024
|
|
|
|
|
thesize = thesize + 1
|
|
|
|
|
Else
|
|
|
|
|
Exit Do
|
|
|
|
|
End If
|
|
|
|
|
Loop
|
|
|
|
|
Select Case filsize
|
|
|
|
|
Case 0 To 9
|
|
|
|
|
spaces = " "
|
|
|
|
|
Case 10 To 99
|
|
|
|
|
spaces = " "
|
|
|
|
|
Case 100 To 999
|
|
|
|
|
spaces = " "
|
|
|
|
|
Case 1000 To 1023
|
|
|
|
|
spaces = " "
|
|
|
|
|
End Select
|
|
|
|
|
Select Case thesize
|
|
|
|
|
Case 1
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine(spaces & filsize & " KB " & filinf.Name)
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Case 2
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine(spaces & filsize & " MB " & filinf.Name)
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Case 3
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine(spaces & filsize & " GB " & filinf.Name)
|
2022-11-06 09:22:35 +00:00
|
|
|
|
End Select
|
|
|
|
|
Next
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Sub NavigateDir(TheDirectory As String)
|
|
|
|
|
If TheDirectory = ".." Then
|
2022-11-13 08:15:05 +00:00
|
|
|
|
If Console.CurrentDirectory = Strings.OnceInfo(1) Then
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine("!\")
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Else
|
2022-11-13 08:15:05 +00:00
|
|
|
|
Console.CurrentDirectory = IO.Directory.GetParent(Console.CurrentDirectory).ToString
|
2022-11-06 09:22:35 +00:00
|
|
|
|
End If
|
|
|
|
|
Else
|
2022-11-13 08:15:05 +00:00
|
|
|
|
If IO.Directory.Exists(Console.CurrentDirectory + "\" + TheDirectory) Then
|
|
|
|
|
Console.CurrentDirectory = Console.CurrentDirectory & "\" & TheDirectory
|
2022-11-06 09:22:35 +00:00
|
|
|
|
ElseIf IO.Directory.Exists(TheDirectory) Then
|
2022-11-13 08:15:05 +00:00
|
|
|
|
Console.CurrentDirectory = TheDirectory
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Else
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine("The directory is not exist!")
|
2022-11-06 09:22:35 +00:00
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Sub CreateDir(TheDirectory As String)
|
2022-11-13 08:15:05 +00:00
|
|
|
|
If IO.Directory.Exists(Console.CurrentDirectory + "\" + TheDirectory) Then
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine("Directory is already exists!")
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Else
|
2022-11-13 08:15:05 +00:00
|
|
|
|
IO.Directory.CreateDirectory(Console.CurrentDirectory + "\" + TheDirectory)
|
2022-11-06 09:22:35 +00:00
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Sub RemoveDir(TheDirectory As String)
|
2022-11-13 08:15:05 +00:00
|
|
|
|
If IO.Directory.Exists(Console.CurrentDirectory + "\" + TheDirectory) Then
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Try
|
2022-11-13 08:15:05 +00:00
|
|
|
|
IO.Directory.Delete(Console.CurrentDirectory + "\" + TheDirectory)
|
2022-11-06 09:22:35 +00:00
|
|
|
|
Catch ex As Exception
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine(ex.Message)
|
2022-11-06 09:22:35 +00:00
|
|
|
|
End Try
|
|
|
|
|
Else
|
2022-11-13 14:22:42 +00:00
|
|
|
|
NewLine("The directory is not exists!")
|
2022-11-06 09:22:35 +00:00
|
|
|
|
End If
|
2022-11-06 08:20:38 +00:00
|
|
|
|
End Sub
|
|
|
|
|
End Module
|