11using Microsoft . VisualBasic ;
22using System ;
33using System . Diagnostics ;
4+ using System . Formats . Tar ;
45using System . IO ;
6+ using System . IO . Compression ;
57using System . Reflection ;
68using System . Reflection . Metadata . Ecma335 ;
79using System . Runtime ;
@@ -822,7 +824,7 @@ private static ExternalTools_Version GetBorielBasicVersion(string exePath)
822824 var v = GetVersionNumber ( version ) ;
823825 int number = v . Item1 ;
824826 int beta = v . Item2 ;
825-
827+
826828 return new ExternalTools_Version ( )
827829 {
828830 DownloadUrl = "" ,
@@ -990,7 +992,7 @@ public static void DownloadAndInstallTool(ExternalTool tool, ExternalTools_Versi
990992 // Extract file
991993 step = $ "Installing { tool . Name } ";
992994 UpdateStatus ( $ "Installing { tool . Name } version { version . Version } ...", 50 ) ;
993- System . IO . Compression . ZipFile . ExtractToDirectory ( tempFile , installationPath , true ) ;
995+ ExtractFile ( tempFile , installationPath ) ;
994996
995997 // Set ZXBS Options
996998 step = "Set ZX Basic Studio options" ;
@@ -1012,6 +1014,73 @@ public static void DownloadAndInstallTool(ExternalTool tool, ExternalTools_Versi
10121014 }
10131015
10141016
1017+ private static void ExtractFile ( string archive , string destination )
1018+ {
1019+ if ( archive . ToLower ( ) . EndsWith ( ".zip" ) )
1020+ {
1021+ System . IO . Compression . ZipFile . ExtractToDirectory ( archive , destination , true ) ;
1022+ }
1023+ else if ( CurrentOperatingSystem != OperatingSystems . Windows )
1024+ {
1025+ Directory . CreateDirectory ( destination ) ;
1026+
1027+ var psi = new ProcessStartInfo
1028+ {
1029+ FileName = "tar" ,
1030+ Arguments = $ "-xzf \" { archive } \" -C \" { destination } \" ",
1031+ RedirectStandardOutput = true ,
1032+ RedirectStandardError = true ,
1033+ UseShellExecute = false ,
1034+ CreateNoWindow = true
1035+ } ;
1036+
1037+ using var process = Process . Start ( psi ) ! ;
1038+
1039+ string stdout = process . StandardOutput . ReadToEnd ( ) ;
1040+ string stderr = process . StandardError . ReadToEnd ( ) ;
1041+
1042+ process . WaitForExit ( ) ;
1043+
1044+ if ( process . ExitCode != 0 )
1045+ {
1046+ ShowMessage ( $ "Error unpacking file { archive } \r \n { stderr } ") ;
1047+ return ;
1048+ }
1049+ }
1050+ //if (archive.ToLower().EndsWith(".tar.gz"))
1051+ //{
1052+ // Directory.CreateDirectory(destination);
1053+
1054+ // using var fileStream = File.OpenRead(archive);
1055+ // using var gzipStream = new GZipStream(fileStream, CompressionMode.Decompress);
1056+ // using var tarReader = new TarReader(gzipStream);
1057+
1058+ // TarEntry? entry;
1059+ // while ((entry = tarReader.GetNextEntry()) != null)
1060+ // {
1061+ // string fullPath = Path.Combine(destination, entry.Name);
1062+
1063+ // if (entry.EntryType == TarEntryType.Directory)
1064+ // {
1065+ // Directory.CreateDirectory(fullPath);
1066+ // }
1067+ // else
1068+ // {
1069+ // Directory.CreateDirectory(Path.GetDirectoryName(fullPath)!);
1070+ // if (entry.Length == 0)
1071+ // {
1072+ // File.WriteAllBytes(fullPath, new byte[0]);
1073+ // }
1074+ // else
1075+ // {
1076+ // entry.DataStream!.CopyTo(File.Create(fullPath));
1077+ // }
1078+ // }
1079+ // }
1080+ //}
1081+ }
1082+
1083+
10151084 private static void SetZXBSConfig ( )
10161085 {
10171086 try
@@ -1049,7 +1118,7 @@ private static void SetZXBSConfig()
10491118 {
10501119 exe += ".exe" ;
10511120 }
1052- var dir = Path . Combine ( GeneralConfig . BasePath , "zxbasic" , exe ) . Replace ( "\\ " , "\\ \\ " ) ;
1121+ var dir = Path . Combine ( GeneralConfig . BasePath , "zxbasic" , exe ) . Replace ( "\\ " , "\\ \\ " ) ;
10531122 line = $ " \" ZxbasmPath\" : \" { dir } \" ,";
10541123 }
10551124 else if ( line . Contains ( "ZxbcPath" ) )
0 commit comments