Not using 7-Zip anymore

This commit is contained in:
Jaex 2018-03-03 00:06:40 +03:00
parent 0cc7d7525b
commit fa22ad8b2a
10 changed files with 29 additions and 37 deletions

Binary file not shown.

View File

@ -33,14 +33,14 @@ using System.Threading.Tasks;
namespace ShareX.HelpersLib namespace ShareX.HelpersLib
{ {
public class ZipManager public static class ZipManager
{ {
public void Extract(string archivePath, string destination) public static void Extract(string archivePath, string destination)
{ {
ZipFile.ExtractToDirectory(archivePath, destination); ZipFile.ExtractToDirectory(archivePath, destination);
} }
public void Extract(string archivePath, string destination, List<string> files) public static void Extract(string archivePath, string destination, List<string> files)
{ {
using (ZipArchive archive = ZipFile.OpenRead(archivePath)) using (ZipArchive archive = ZipFile.OpenRead(archivePath))
{ {
@ -60,7 +60,17 @@ namespace ShareX.HelpersLib
} }
} }
public void Compress(string archivePath, List<string> files, string workingDirectory = "") public static void Compress(string source, string archivePath, CompressionLevel compression = CompressionLevel.Optimal)
{
if (File.Exists(archivePath))
{
File.Delete(archivePath);
}
ZipFile.CreateFromDirectory(source, archivePath, compression, false);
}
public static void Compress(string archivePath, List<string> files, string workingDirectory = "", CompressionLevel compression = CompressionLevel.Optimal)
{ {
if (File.Exists(archivePath)) if (File.Exists(archivePath))
{ {
@ -71,7 +81,7 @@ namespace ShareX.HelpersLib
{ {
foreach (string file in files) foreach (string file in files)
{ {
archive.CreateEntryFromFile(Path.Combine(workingDirectory, file), file); archive.CreateEntryFromFile(Path.Combine(workingDirectory, file), file, compression);
} }
} }
} }

View File

@ -59,9 +59,8 @@ namespace ShareX.MediaLib
{ {
try try
{ {
ZipManager zipManager = new ZipManager();
List<string> files = new List<string>() { "ffmpeg.exe" }; List<string> files = new List<string>() { "ffmpeg.exe" };
zipManager.Extract(archivePath, extractPath, files); ZipManager.Extract(archivePath, extractPath, files);
return true; return true;
} }
catch (Exception e) catch (Exception e)

View File

@ -117,16 +117,6 @@ namespace ShareX.Setup
} }
} }
public static void Zip(string source, string target)
{
ProcessStart(Path.GetFullPath(Program.SevenZipPath), $"a -tzip \"{target}\" \"{source}\" -r -mx=9");
}
public static void Unzip(string source, string extract)
{
ProcessStart(Path.GetFullPath(Program.SevenZipPath), $"e \"{source}\" \"{extract}\" -r");
}
private static void ProcessStart(string filePath, string arguments) private static void ProcessStart(string filePath, string arguments)
{ {
Console.WriteLine($"Process starting: {filePath} {arguments}"); Console.WriteLine($"Process starting: {filePath} {arguments}");

View File

@ -56,7 +56,6 @@ Name: "CreateStartupIcon"; Description: "Run ShareX when Windows starts"; GroupD
Source: "{#MyAppFilepath}"; DestDir: {app}; Flags: ignoreversion Source: "{#MyAppFilepath}"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppFilepath}.config"; DestDir: {app}; Flags: ignoreversion Source: "{#MyAppFilepath}.config"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppReleaseDirectory}\*.dll"; DestDir: {app}; Flags: ignoreversion Source: "{#MyAppReleaseDirectory}\*.dll"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppReleaseDirectory}\7za.exe"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppRootDirectory}\Licenses\*.txt"; DestDir: {app}\Licenses; Flags: ignoreversion Source: "{#MyAppRootDirectory}\Licenses\*.txt"; DestDir: {app}\Licenses; Flags: ignoreversion
Source: "{#MyAppOutputDirectory}\Recorder-devices-setup.exe"; DestDir: {app}; Flags: ignoreversion Source: "{#MyAppOutputDirectory}\Recorder-devices-setup.exe"; DestDir: {app}; Flags: ignoreversion
Source: "{#MyAppRootDirectory}\ShareX.NativeMessagingHost\bin\Release\ShareX_NativeMessagingHost.exe"; DestDir: {app}; Flags: ignoreversion Source: "{#MyAppRootDirectory}\ShareX.NativeMessagingHost\bin\Release\ShareX_NativeMessagingHost.exe"; DestDir: {app}; Flags: ignoreversion

View File

@ -23,7 +23,9 @@
#endregion License Information (GPL v3) #endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -236,7 +238,6 @@ namespace ShareX.Setup
Helpers.CopyFile(Path.Combine(source, "ShareX.exe"), destination); Helpers.CopyFile(Path.Combine(source, "ShareX.exe"), destination);
Helpers.CopyFile(Path.Combine(source, "ShareX.exe.config"), destination); Helpers.CopyFile(Path.Combine(source, "ShareX.exe.config"), destination);
Helpers.CopyFile(Path.Combine(source, "7za.exe"), destination);
if (job == SetupJobs.CreateWindowsStoreFolder || job == SetupJobs.CreateWindowsStoreDebugFolder) if (job == SetupJobs.CreateWindowsStoreFolder || job == SetupJobs.CreateWindowsStoreDebugFolder)
{ {
@ -294,13 +295,7 @@ namespace ShareX.Setup
//FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(releaseDir, "ShareX.exe")); //FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(releaseDir, "ShareX.exe"));
//string zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart); //string zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart);
string zipPath = Path.Combine(OutputDir, "ShareX-portable.zip"); string zipPath = Path.Combine(OutputDir, "ShareX-portable.zip");
ZipManager.Compress(Path.GetFullPath(destination), Path.GetFullPath(zipPath));
if (File.Exists(zipPath))
{
File.Delete(zipPath);
}
Helpers.Zip(Path.GetFullPath(destination) + "\\*", Path.GetFullPath(zipPath));
Directory.Delete(destination, true); Directory.Delete(destination, true);
} }
@ -315,7 +310,7 @@ namespace ShareX.Setup
if (!File.Exists(FFmpeg32bit)) if (!File.Exists(FFmpeg32bit))
{ {
string filename = Helpers.DownloadFile("http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20171130-83ecdc9-win32-static.zip"); string filename = Helpers.DownloadFile("http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20171130-83ecdc9-win32-static.zip");
Helpers.Unzip(filename, "ffmpeg.exe"); ZipManager.Extract(filename, "", new List<string>() { "ffmpeg.exe" });
File.Move("ffmpeg.exe", FFmpeg32bit); File.Move("ffmpeg.exe", FFmpeg32bit);
} }
@ -327,7 +322,7 @@ namespace ShareX.Setup
if (!File.Exists(FFmpeg64bit)) if (!File.Exists(FFmpeg64bit))
{ {
string filename = Helpers.DownloadFile("http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20171130-83ecdc9-win64-static.zip"); string filename = Helpers.DownloadFile("http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20171130-83ecdc9-win64-static.zip");
Helpers.Unzip(filename, "ffmpeg.exe"); ZipManager.Extract(filename, "", new List<string>() { "ffmpeg.exe" });
File.Move("ffmpeg.exe", FFmpeg64bit); File.Move("ffmpeg.exe", FFmpeg64bit);
} }

View File

@ -86,6 +86,12 @@
<ItemGroup> <ItemGroup>
<Content Include="WindowsStore\AppxManifest.xml" /> <Content Include="WindowsStore\AppxManifest.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ShareX.HelpersLib\ShareX.HelpersLib.csproj">
<Project>{327750e1-9fb7-4cc3-8aea-9bc42180cad3}</Project>
<Name>ShareX.HelpersLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -104,7 +104,6 @@ Icons: http://p.yusukekamiyamane.com
ImageListView: https://github.com/oozcitak/imagelistview ImageListView: https://github.com/oozcitak/imagelistview
FFmpeg: http://www.ffmpeg.org FFmpeg: http://www.ffmpeg.org
Zeranoe FFmpeg: http://ffmpeg.zeranoe.com/builds Zeranoe FFmpeg: http://ffmpeg.zeranoe.com/builds
7-Zip: http://www.7-zip.org
DirectShow video and audio device: https://github.com/rdp/screen-capture-recorder-to-video-windows-free DirectShow video and audio device: https://github.com/rdp/screen-capture-recorder-to-video-windows-free
FluentFTP: https://github.com/robinrodricks/FluentFTP FluentFTP: https://github.com/robinrodricks/FluentFTP
Steamworks.NET: https://github.com/rlabrecque/Steamworks.NET Steamworks.NET: https://github.com/rlabrecque/Steamworks.NET

View File

@ -281,8 +281,7 @@ namespace ShareX
files.Add($"{Program.LogsFoldername}\\*.txt"); files.Add($"{Program.LogsFoldername}\\*.txt");
} }
ZipManager zipManager = new ZipManager(); ZipManager.Compress(archivePath, files, Program.PersonalFolder);
zipManager.Compress(archivePath, files, Program.PersonalFolder);
return true; return true;
} }
catch (Exception e) catch (Exception e)
@ -298,8 +297,7 @@ namespace ShareX
{ {
try try
{ {
ZipManager zipManager = new ZipManager(); ZipManager.Extract(archivePath, Program.PersonalFolder);
zipManager.Extract(archivePath, Program.PersonalFolder);
return true; return true;
} }
catch (Exception e) catch (Exception e)

View File

@ -1365,10 +1365,6 @@
<None Include="Resources\network-ip.png" /> <None Include="Resources\network-ip.png" />
<None Include="Resources\ruler-triangle.png" /> <None Include="Resources\ruler-triangle.png" />
<None Include="Resources\application-network.png" /> <None Include="Resources\application-network.png" />
<None Include="..\Lib\7za.exe">
<Link>7za.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\barcode-2d.png" /> <None Include="Resources\barcode-2d.png" />
<None Include="Resources\GitHub.png" /> <None Include="Resources\GitHub.png" />
<None Include="Resources\Twitter.ico" /> <None Include="Resources\Twitter.ico" />