Optimization on UNZIP

This commit is contained in:
EverythingWindows 2022-11-20 19:50:10 +07:00
parent 2fa56446be
commit 9d384be175
2 changed files with 4 additions and 5 deletions

View file

@ -152,7 +152,7 @@
Case "unzip" Case "unzip"
If Strings.AvailableFeature(33) = "1" Then If Strings.AvailableFeature(33) = "1" Then
TempUsage = TempUsage & "unzip [FILENAME.ZIP]" TempUsage = TempUsage & "unzip [FILENAME.ZIP]"
Console.TextBox1.Text = Console.TextBox1.Text & TempUsage & Environment.NewLine & Environment.NewLine & My.Resources.man_unzip & Environment.NewLine 'Console.TextBox1.Text = Console.TextBox1.Text & TempUsage & Environment.NewLine & Environment.NewLine & My.Resources.man_unzip & Environment.NewLine
NormalCommand() NormalCommand()
End If End If
Case "ver" Case "ver"

View file

@ -8,10 +8,8 @@ Module Com_Unzip
UnzipString = RawCommand.Substring(6) UnzipString = RawCommand.Substring(6)
If UnzipString Like "-d '*.zip'" Then If UnzipString Like "-d '*.zip'" Then
Dim UnzipEXE() As String = UnzipString.Split("''") Dim UnzipEXE() As String = UnzipString.Split("''")
NewLine(UnzipEXE(1))
If File.Exists(Console.CurrentDirectory & "\" & UnzipEXE(1)) = True Then If File.Exists(Console.CurrentDirectory & "\" & UnzipEXE(1)) = True Then
Dim UnzipDir As String = UnzipEXE(1).Replace(".zip", "") Dim UnzipDir As String = UnzipEXE(1).Replace(".zip", "")
NewLine(UnzipDir)
Dim UnzipRandomInt As Integer Dim UnzipRandomInt As Integer
Dim UnzipRandom As New Random Dim UnzipRandom As New Random
UnzipRandomInt = UnzipRandom.Next(1, 1000000) UnzipRandomInt = UnzipRandom.Next(1, 1000000)
@ -30,10 +28,8 @@ Module Com_Unzip
End If End If
If UnzipString Like "-f '*.zip'" Then If UnzipString Like "-f '*.zip'" Then
Dim UnzipEXE() As String = UnzipString.Split("''") Dim UnzipEXE() As String = UnzipString.Split("''")
NewLine(UnzipEXE(1))
If File.Exists(Console.CurrentDirectory & "\" & UnzipEXE(1)) = True Then If File.Exists(Console.CurrentDirectory & "\" & UnzipEXE(1)) = True Then
Dim UnzipDir As String = UnzipEXE(1).Replace(".zip", "") Dim UnzipDir As String = UnzipEXE(1).Replace(".zip", "")
NewLine(UnzipDir)
Dim UnzipRandomInt As Integer Dim UnzipRandomInt As Integer
Dim UnzipRandom As New Random Dim UnzipRandom As New Random
UnzipRandomInt = UnzipRandom.Next(1, 1000000) UnzipRandomInt = UnzipRandom.Next(1, 1000000)
@ -80,6 +76,7 @@ Module Com_Unzip
NewLine("Copying " & ChildFile.Name & "...") NewLine("Copying " & ChildFile.Name & "...")
If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then
ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), False) ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), False)
AddLine(" OK")
End If End If
End If End If
Next Next
@ -87,8 +84,10 @@ Module Com_Unzip
' copy all the sub-directories by recursively calling this same routine ' copy all the sub-directories by recursively calling this same routine
Dim SubDir As DirectoryInfo Dim SubDir As DirectoryInfo
For Each SubDir In SourceDir.GetDirectories() For Each SubDir In SourceDir.GetDirectories()
NewLine("Copying " & SubDir.Name & "...")
CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName,
SubDir.Name), Overwrite) SubDir.Name), Overwrite)
AddLine(" OK")
Next Next
Else Else
Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName) Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName)