diff --git a/ShiftOS-TheRevival/API/TerminalAPI.vb b/ShiftOS-TheRevival/API/TerminalAPI.vb index c6c8535..eb0f10b 100644 --- a/ShiftOS-TheRevival/API/TerminalAPI.vb +++ b/ShiftOS-TheRevival/API/TerminalAPI.vb @@ -1,4 +1,6 @@ -Module TerminalAPI +Imports System.IO.Compression + +Module TerminalAPI Public command As String Public AdvancedCommand As Boolean Public RawCommand As String @@ -298,6 +300,12 @@ End If If command Like "color *" Then GetColor("terminal", command.Substring(6, 1), command.Substring(7, 1)) + AdvancedCommand = False + NormalCommand() + End If + If command Like "copy *" Then + Copy() + AdvancedCommand = False NormalCommand() End If If command Like "cowsay *" Then @@ -395,6 +403,20 @@ NormalCommand() End If End If + If command Like "unzip *" Then + If Strings.AvailableFeature(33) = 1 Then + Unzip() + End If + AdvancedCommand = False + NormalCommand() + End If + If command Like "zip *" Then + If Strings.AvailableFeature(32) = 1 Then + Zip() + End If + AdvancedCommand = False + NormalCommand() + End If End If If Console.BadCommand = True Then NewLine("Bad command or wrong file name") diff --git a/ShiftOS-TheRevival/Functions/InGame/ROMs/Strings.vb b/ShiftOS-TheRevival/Functions/InGame/ROMs/Strings.vb index 325f583..25794b5 100644 --- a/ShiftOS-TheRevival/Functions/InGame/ROMs/Strings.vb +++ b/ShiftOS-TheRevival/Functions/InGame/ROMs/Strings.vb @@ -3,7 +3,7 @@ Public Shared ComputerInfo(6) As String Public Shared IsFree As Boolean Public Shared OnceInfo(8) As String - Public Shared AvailableFeature(31) As String + Public Shared AvailableFeature(35) As String Public Shared CLIInterpreter As String Public Shared SaveFile As String Public Shared Achievement As String @@ -80,6 +80,8 @@ '29 = Date by general [Shows date in general DD/MM/YYYY format] (0.2.5) (default : 0) '30 = Batch-file support for ShiftOS [Gives execution support for ShiftOS Script File (.scr)] (0.2.5) (default : 0) '31 = Rename support [Ability to rename files in ShiftOS] (default : 0) + '32 = Zip command [Ability to compress file in a zip file] (default : 0) + '33 = Unzip command [Ability to extract file in a zip file] (default : 0) ' 'Features bought hierarchy : 'ShiftOS Key (KEY) (5 CP) @@ -100,6 +102,8 @@ '>>>>>>RGB Variant (rgb2) (75 CP) '>>>>>>>4-bit Color Display (4BITCOLOR) (80 CP) '>>>>>>>>Terminal Read-Only Memory Driver (ROMDRIVER, DIR, MKDIR, RMDIR, CD, PWD) (90 CP) + '>>>>>>>>>ZIP command (ZIP) (95 CP) + '>>>>>>>>>UNZIP command (UNZIP) (95 CP) '>>>>>>>>>Rename support (RENAME) (95 CP) '>>>>>>>>>TextPad (100 CP) '>>>>>>>>>>ShiftOS Batch Script Support (BATCHSCRIPT) (100 CP) diff --git a/ShiftOS-TheRevival/Functions/InGame/StoreManager/Shiftoriums.vb b/ShiftOS-TheRevival/Functions/InGame/StoreManager/Shiftoriums.vb index dcc0fb1..af57f18 100644 --- a/ShiftOS-TheRevival/Functions/InGame/StoreManager/Shiftoriums.vb +++ b/ShiftOS-TheRevival/Functions/InGame/StoreManager/Shiftoriums.vb @@ -59,6 +59,12 @@ If Strings.AvailableFeature(31) = "0" Then NewLine("(rename | 95 CP) Rename command") End If + If Strings.AvailableFeature(32) = 0 Then + NewLine("(zip | 95 CP) Zip command") + End If + If Strings.AvailableFeature(33) = 0 Then + NewLine("(unzip | 95 CP) Unzip command") + End If End If End If End If @@ -392,6 +398,28 @@ NewLine(ManHeader(1)) NormalCommand() End If + Case "zip" + If Strings.AvailableFeature(32) = "0" Then + ManHeader(0) = "Zip command" + ManHeader(1) = "95 CP" + NewLine(ManHeader(0)) + NewLine(Nothing) + NewLine("Gives ShiftOS support for compressing a file or directory into a ZIP file") + NewLine(Nothing) + NewLine(ManHeader(1)) + NormalCommand() + End If + Case "unzip" + If Strings.AvailableFeature(33) = "0" Then + ManHeader(0) = "Unzip command" + ManHeader(1) = "95 CP" + NewLine(ManHeader(0)) + NewLine(Nothing) + NewLine("Gives ShiftOS support for compressing extracting a file or directory from a ZIP file") + NewLine(Nothing) + NewLine(ManHeader(1)) + NormalCommand() + End If Case Else NormalCommand() Console.TextBox1.Text = Console.TextBox1.Text & Environment.NewLine & "Shiftorium: Bad command or not available" @@ -497,6 +525,12 @@ Case "rename" Shiftorium_InstallFeatures(True, "rename", 31, 95) NormalCommand() + Case "zip" + Shiftorium_InstallFeatures(True, "zip", 32, 95) + NormalCommand() + Case "unzip" + Shiftorium_InstallFeatures(True, "unzip", 33, 95) + NormalCommand() Case Else NormalCommand() NewLine("Shiftorium: Bad command or not available") @@ -588,6 +622,8 @@ Strings.AvailableFeature(16) = "1" Strings.AvailableFeature(17) = "0" Strings.AvailableFeature(31) = "0" + Strings.AvailableFeature(32) = "0" + Strings.AvailableFeature(33) = "0" success = True Case "textpad" Strings.AvailableFeature(17) = "1" @@ -648,6 +684,12 @@ Case "rename" Strings.AvailableFeature(31) = "1" success = True + Case "zip" + Strings.AvailableFeature(32) = "1" + success = True + Case "unzip" + Strings.AvailableFeature(33) = "1" + success = True End Select If success = False Then If IsCLI = True Then diff --git a/ShiftOS-TheRevival/Functions/OutGame/TheUpdater.vb b/ShiftOS-TheRevival/Functions/OutGame/TheUpdater.vb index ca1f7d9..28b827e 100644 --- a/ShiftOS-TheRevival/Functions/OutGame/TheUpdater.vb +++ b/ShiftOS-TheRevival/Functions/OutGame/TheUpdater.vb @@ -100,6 +100,15 @@ Module TheUpdater Else Strings.AvailableFeature(30) = "2" End If + If Strings.AvailableFeature(16) = 1 Then + Strings.AvailableFeature(31) = 0 + Strings.AvailableFeature(32) = 0 + Strings.AvailableFeature(33) = 0 + Else + Strings.AvailableFeature(31) = 2 + Strings.AvailableFeature(32) = 2 + Strings.AvailableFeature(33) = 2 + End If Strings.ComputerInfo(0) = ComputerInfoHere(0) Strings.ComputerInfo(1) = ComputerInfoHere(1) Strings.ComputerInfo(2) = ComputerInfoHere(2) @@ -107,6 +116,65 @@ Module TheUpdater Strings.ComputerInfo(4) = ComputerInfoHere(4) Strings.ComputerInfo(5) = "0F" Strings.ComputerInfo(6) = "F0" + If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") = True Then + + Else + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") + End If + ShiftOSUpdater.Button2.Text = "Updated!" + Case "0.2.5" + Strings.AvailableFeature(0) = AvailableFeatureHere(0) + Strings.AvailableFeature(1) = AvailableFeatureHere(1) + Strings.AvailableFeature(2) = AvailableFeatureHere(2) + Strings.AvailableFeature(3) = AvailableFeatureHere(3) + Strings.AvailableFeature(4) = AvailableFeatureHere(4) + Strings.AvailableFeature(5) = AvailableFeatureHere(5) + Strings.AvailableFeature(6) = AvailableFeatureHere(6) + Strings.AvailableFeature(7) = AvailableFeatureHere(7) + Strings.AvailableFeature(8) = AvailableFeatureHere(8) + Strings.AvailableFeature(9) = AvailableFeatureHere(9) + Strings.AvailableFeature(10) = AvailableFeatureHere(10) + Strings.AvailableFeature(11) = AvailableFeatureHere(11) + Strings.AvailableFeature(12) = AvailableFeatureHere(12) + Strings.AvailableFeature(13) = AvailableFeatureHere(13) + Strings.AvailableFeature(14) = AvailableFeatureHere(14) + Strings.AvailableFeature(15) = AvailableFeatureHere(15) + Strings.AvailableFeature(16) = AvailableFeatureHere(16) + Strings.AvailableFeature(17) = AvailableFeatureHere(17) + Strings.AvailableFeature(18) = AvailableFeatureHere(18) + Strings.AvailableFeature(19) = AvailableFeatureHere(19) + Strings.AvailableFeature(20) = AvailableFeatureHere(20) + Strings.AvailableFeature(21) = AvailableFeatureHere(21) + Strings.AvailableFeature(22) = AvailableFeatureHere(22) + Strings.AvailableFeature(23) = AvailableFeatureHere(23) + Strings.AvailableFeature(24) = AvailableFeatureHere(24) + Strings.AvailableFeature(25) = AvailableFeatureHere(25) + Strings.AvailableFeature(26) = AvailableFeatureHere(26) + Strings.AvailableFeature(27) = AvailableFeatureHere(27) + Strings.AvailableFeature(28) = AvailableFeatureHere(28) + Strings.AvailableFeature(29) = AvailableFeatureHere(29) + Strings.AvailableFeature(30) = AvailableFeatureHere(30) + If Strings.AvailableFeature(16) = 1 Then + Strings.AvailableFeature(31) = 0 + Strings.AvailableFeature(32) = 0 + Strings.AvailableFeature(33) = 0 + Else + Strings.AvailableFeature(31) = 2 + Strings.AvailableFeature(32) = 2 + Strings.AvailableFeature(33) = 2 + End If + Strings.ComputerInfo(0) = ComputerInfoHere(0) + Strings.ComputerInfo(1) = ComputerInfoHere(1) + Strings.ComputerInfo(2) = ComputerInfoHere(2) + Strings.ComputerInfo(3) = ComputerInfoHere(3) + Strings.ComputerInfo(4) = ComputerInfoHere(4) + Strings.ComputerInfo(5) = "0F" + Strings.ComputerInfo(6) = "F0" + If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") = True Then + + Else + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") + End If ShiftOSUpdater.Button2.Text = "Updated!" End Select File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\version.txt", My.Resources.CurrentVersion) diff --git a/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb b/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb index bd61679..6404c76 100644 --- a/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb +++ b/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb @@ -47,6 +47,8 @@ Module SaveLoadSystem Strings.AvailableFeature(30) = "2" '0.2.6 Features Strings.AvailableFeature(31) = "2" + Strings.AvailableFeature(32) = "2" + Strings.AvailableFeature(33) = "2" End Sub Public Sub FreeRoamMode() @@ -90,6 +92,8 @@ Module SaveLoadSystem Strings.AvailableFeature(30) = "1" '0.2.6 Features Strings.AvailableFeature(31) = "1" + Strings.AvailableFeature(32) = "1" + Strings.AvailableFeature(33) = "1" End Sub Public Sub GodMode() @@ -132,6 +136,8 @@ Module SaveLoadSystem Strings.AvailableFeature(30) = "2" '0.2.6 Features Strings.AvailableFeature(31) = "2" + Strings.AvailableFeature(32) = "2" + Strings.AvailableFeature(33) = "2" End Sub Public Sub SaveGame() diff --git a/ShiftOS-TheRevival/MainForms/ShiftOSMenu.vb b/ShiftOS-TheRevival/MainForms/ShiftOSMenu.vb index 53f4fef..8a65f59 100644 --- a/ShiftOS-TheRevival/MainForms/ShiftOSMenu.vb +++ b/ShiftOS-TheRevival/MainForms/ShiftOSMenu.vb @@ -167,9 +167,15 @@ Public Class ShiftOSMenu Else Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\saved") End If + If Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") = True Then + + Else + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") + End If Else Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS") Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\ShiftFS") + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS") Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\saved") File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\version.txt", My.Resources.CurrentVersion) End If diff --git a/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj b/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj index f8a83a4..cd26b45 100644 --- a/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj +++ b/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj @@ -72,6 +72,8 @@ + + @@ -170,6 +172,7 @@ + @@ -184,6 +187,7 @@ + @@ -205,6 +209,7 @@ True + diff --git a/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Copy.vb b/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Copy.vb new file mode 100644 index 0000000..74f8e20 --- /dev/null +++ b/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Copy.vb @@ -0,0 +1,23 @@ +Imports System.IO + +Module Com_Copy + Public CopyString As String + + Public Sub Copy() + 'CopyString = RawCommand + If RawCommand Like "copy '*' '*'" Then + Dim CopyEXE() As String = RawCommand.Split("''") + Dim DestFile As String = CopyEXE(2) + NewLine(DestFile) + DestFile.Replace("!", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\ShiftFS") + CopyEXE(2) = DestFile + NewLine(CopyEXE(2) & "\" & CopyEXE(1)) + If File.Exists(Console.CurrentDirectory & "\" & CopyEXE(1)) = True Then + If Directory.Exists(CopyEXE(2)) = True Then + NewLine(Console.CurrentDirectory & "\" & CopyEXE(1)) + File.Copy(Console.CurrentDirectory & "\" & CopyEXE(1), CopyEXE(2) & "\" & CopyEXE(1)) + End If + End If + End If + End Sub +End Module diff --git a/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Unzip.vb b/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Unzip.vb new file mode 100644 index 0000000..8dcc8c6 --- /dev/null +++ b/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Unzip.vb @@ -0,0 +1,96 @@ +Imports System.IO +Imports System.IO.Compression + +Module Com_Unzip + Public UnzipString As String + + Public Sub Unzip() + UnzipString = RawCommand.Substring(6) + If UnzipString Like "-d '*.zip'" Then + Dim UnzipEXE() As String = UnzipString.Split("''") + NewLine(UnzipEXE(1)) + If File.Exists(Console.CurrentDirectory & "\" & UnzipEXE(1)) = True Then + Dim UnzipDir As String = UnzipEXE(1).Replace(".zip", "") + NewLine(UnzipDir) + Dim UnzipRandomInt As Integer + Dim UnzipRandom As New Random + UnzipRandomInt = UnzipRandom.Next(1, 1000000) + NewLine("Creating temporary place for selected archive...") + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt) + NewLine("Extracting the file from a zip file...") + ZipFile.ExtractToDirectory(Console.CurrentDirectory & "\" & UnzipEXE(1), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt) + NewLine("Copying the extracted file into the current directory...") + Directory.CreateDirectory(Console.CurrentDirectory & "\" & UnzipDir) + CopyDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt, Console.CurrentDirectory & "\" & UnzipDir) + NewLine("Removing temporary place of the file...") + Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt, True) + Else + + End If + End If + If UnzipString Like "-h '*.zip'" Then + Dim UnzipEXE() As String = UnzipString.Split("''") + NewLine(UnzipEXE(1)) + If File.Exists(Console.CurrentDirectory & "\" & UnzipEXE(1)) = True Then + Dim UnzipDir As String = UnzipEXE(1).Replace(".zip", "") + NewLine(UnzipDir) + Dim UnzipRandomInt As Integer + Dim UnzipRandom As New Random + UnzipRandomInt = UnzipRandom.Next(1, 1000000) + NewLine("Creating temporary place for selected archive...") + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt) + NewLine("Extracting the file from a zip file...") + ZipFile.ExtractToDirectory(Console.CurrentDirectory & "\" & UnzipEXE(1), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt) + NewLine("Copying the extracted file into the current directory...") + Directory.CreateDirectory(Console.CurrentDirectory & "\" & UnzipDir) + CopyDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt, Console.CurrentDirectory) + NewLine("Removing temporary place of the file...") + Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\UNZIP" & UnzipRandomInt, True) + Else + + End If + End If + End Sub + + Public Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, Optional ByVal Overwrite As Boolean = False) + Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourcePath) + Dim DestDir As DirectoryInfo = New DirectoryInfo(DestPath) + + ' the source directory must exist, otherwise throw an exception + If SourceDir.Exists Then + ' if destination SubDir's parent SubDir does not exist throw an exception + If Not DestDir.Parent.Exists Then + Throw New DirectoryNotFoundException _ + ("Destination directory does not exist: " + DestDir.Parent.FullName) + End If + + If Not DestDir.Exists Then + DestDir.Create() + End If + + ' copy all the files of the current directory + Dim ChildFile As FileInfo + For Each ChildFile In SourceDir.GetFiles() + If Overwrite Then + ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), True) + Else + ' if Overwrite = false, copy the file only if it does not exist + ' this is done to avoid an IOException if a file already exists + ' this way the other files can be copied anyway... + If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then + ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), False) + End If + End If + Next + + ' copy all the sub-directories by recursively calling this same routine + Dim SubDir As DirectoryInfo + For Each SubDir In SourceDir.GetDirectories() + CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, + SubDir.Name), Overwrite) + Next + Else + Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName) + End If + End Sub +End Module diff --git a/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Zip.vb b/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Zip.vb new file mode 100644 index 0000000..b48d2ae --- /dev/null +++ b/ShiftOS-TheRevival/TerminalApplications/Internal/Com_Zip.vb @@ -0,0 +1,37 @@ +Imports System.IO +Imports System.IO.Compression + +Module Com_Zip + Public ZipString As String + + Public Sub Zip() + ZipString = RawCommand.Substring(4) + If ZipString Like "-f '*.zip' '*'" Then + Dim ZipEXE() As String = ZipString.Split("''") + If File.Exists(Console.CurrentDirectory & "\" & ZipEXE(3)) = True Then + Dim ZipRandomInt As Integer + Dim ZipRandom As New Random + ZipRandomInt = ZipRandom.Next(1, 1000000) + NewLine("Creating temporary place for selected file...") + Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\ZIP" & ZipRandomInt) + NewLine("Assigning place for the selected file...") + File.Copy(Console.CurrentDirectory & "\" & ZipEXE(3), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\ZIP" & ZipRandomInt & "\" & ZipEXE(3)) + NewLine("Compressing the file into a zip file...") + ZipFile.CreateFromDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\ZIP" & ZipRandomInt, Console.CurrentDirectory & "\" & ZipEXE(1)) + NewLine("Removing temporary place of the file...") + Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\SysShiftFS\ZIP" & ZipRandomInt, True) + Else + + End If + End If + If ZipString Like "-d '*.zip' '*'" Then + Dim ZipEXE() As String = ZipString.Split("''") + If Directory.Exists(Console.CurrentDirectory & "\" & ZipEXE(3)) = True Then + NewLine("Compressing the directory into a zip file...") + ZipFile.CreateFromDirectory(Console.CurrentDirectory & "\" & ZipEXE(3), Console.CurrentDirectory & "\" & ZipEXE(1)) + Else + + End If + End If + End Sub +End Module