DotNetZip is currently unusable with Xamarin.Mac so disable it until

upstream corrects.
This commit is contained in:
2017-05-16 05:14:39 +01:00
parent 286589478c
commit 63a2b16c32
8 changed files with 40 additions and 17 deletions

View File

@@ -51,6 +51,7 @@ namespace osrepodbmgr.Core
public static BlockMediaType workingDisk;
public static CICMMetadataType metadata;
public static bool userExtracting;
public static bool usableDotNetZip;
public delegate void UnarChangeStatusDelegate();
public static event UnarChangeStatusDelegate UnarChangeStatus;

View File

@@ -1151,14 +1151,18 @@ namespace osrepodbmgr.Core
if(Context.archiveFormat == "Zip")
{
Context.unzipWithUnAr = true;
ZipFile zf = ZipFile.Read(Context.path, new ReadOptions { Encoding = Encoding.UTF8 });
foreach(ZipEntry ze in zf)
if(Context.usableDotNetZip)
{
// ZIP created with Mac OS X, need to be extracted with The UnArchiver to get correct ResourceFork structure
if(ze.FileName.StartsWith("__MACOSX", StringComparison.CurrentCulture))
ZipFile zf = ZipFile.Read(Context.path, new ReadOptions { Encoding = Encoding.UTF8 });
foreach(ZipEntry ze in zf)
{
Context.unzipWithUnAr = false;
break;
// ZIP created with Mac OS X, need to be extracted with The UnArchiver to get correct ResourceFork structure
if(ze.FileName.StartsWith("__MACOSX", StringComparison.CurrentCulture))
{
Context.unzipWithUnAr = false;
break;
}
}
}
}
@@ -1215,7 +1219,7 @@ namespace osrepodbmgr.Core
try
{
// If it's a ZIP file not created by Mac OS X, use DotNetZip to uncompress (unar freaks out or corrupts certain ZIP features)
if(Context.archiveFormat == "Zip" && !Context.unzipWithUnAr)
if(Context.archiveFormat == "Zip" && !Context.unzipWithUnAr && Context.usableDotNetZip)
{
try
{
@@ -1591,6 +1595,13 @@ namespace osrepodbmgr.Core
return;
}
if(!Context.usableDotNetZip)
{
if(Failed != null)
Failed("Cannot create ZIP files");
return;
}
ZipFile zf = new ZipFile(Context.path, Encoding.UTF8);
zf.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
zf.CompressionMethod = CompressionMethod.Deflate;

View File

@@ -39,6 +39,8 @@ namespace osrepodbmgr.Eto.Desktop
{
Settings.LoadSettings();
Context.CheckUnar();
Context.usableDotNetZip = !Platform.Detect.IsMac && !Platform.Detect.IsIos;
new Application(Platform.Detect).Run(new frmMain());
}
}

View File

@@ -39,6 +39,7 @@ namespace osrepodbmgr.Eto.XamMac2
{
Settings.LoadSettings();
Context.CheckUnar();
Context.usableDotNetZip = false;
new Application(Platforms.XamMac2).Run(new frmMain());
}
}

View File

@@ -39,7 +39,7 @@
<ButtonMenuItem Text="Add" Click="OnBtnAddClicked" Shortcut="CommonModifier+A" />
<ButtonMenuItem Text="Remove" Click="OnBtnRemoveClicked" Shortcut="CommonModifier+R" />
<ButtonMenuItem Text="Save As" Click="OnBtnSaveClicked" Shortcut="CommonModifier+S" />
<ButtonMenuItem Text="Compress" Click="OnBtnCompressClicked" Shortcut="CommonModifier+E" />
<ButtonMenuItem ID="mnuCompress" Text="Compress" Click="OnBtnCompressClicked" Shortcut="CommonModifier+E" />
</ButtonMenuItem>
<ButtonMenuItem Text="Help" ID="btnHelp" Click="OnBtnHelpClicked" />
<MenuBar.ApplicationItems>

View File

@@ -55,6 +55,7 @@ namespace osrepodbmgr.Eto
Button btnStop;
ButtonMenuItem btnSettings;
ButtonMenuItem btnHelp;
ButtonMenuItem mnuCompress;
#pragma warning restore 0649
#endregion XAML UI elements
@@ -144,6 +145,12 @@ namespace osrepodbmgr.Eto
prgProgress.Indeterminate = true;
if(!Context.usableDotNetZip)
{
btnCompress.Visible = false;
mnuCompress.Enabled = false;
}
Workers.Failed += LoadOSesFailed;
Workers.Finished += LoadOSesFinished;
Workers.UpdateProgress += UpdateProgress;
@@ -187,7 +194,7 @@ namespace osrepodbmgr.Eto
treeOSes.Enabled = true;
btnAdd.Visible = true;
btnRemove.Visible = true;
btnCompress.Visible = true;
btnCompress.Visible = Context.usableDotNetZip;
btnSave.Visible = true;
btnHelp.Enabled = true;
btnSettings.Enabled = true;
@@ -318,7 +325,7 @@ namespace osrepodbmgr.Eto
treeOSes.Enabled = true;
btnAdd.Visible = true;
btnRemove.Visible = true;
btnCompress.Visible = true;
btnCompress.Visible = Context.usableDotNetZip;
btnSave.Visible = true;
btnHelp.Enabled = true;
btnSettings.Enabled = true;
@@ -350,7 +357,7 @@ namespace osrepodbmgr.Eto
treeOSes.Enabled = true;
btnAdd.Visible = true;
btnRemove.Visible = true;
btnCompress.Visible = true;
btnCompress.Visible = Context.usableDotNetZip;
btnSave.Visible = true;
btnHelp.Enabled = true;
btnSettings.Enabled = true;
@@ -461,7 +468,7 @@ namespace osrepodbmgr.Eto
treeOSes.Enabled = true;
btnAdd.Visible = true;
btnRemove.Visible = true;
btnCompress.Visible = true;
btnCompress.Visible = Context.usableDotNetZip;
btnSave.Visible = true;
btnHelp.Enabled = true;
btnSettings.Enabled = true;
@@ -493,7 +500,7 @@ namespace osrepodbmgr.Eto
treeOSes.Enabled = true;
btnAdd.Visible = true;
btnRemove.Visible = true;
btnCompress.Visible = true;
btnCompress.Visible = Context.usableDotNetZip;
btnSave.Visible = true;
btnHelp.Enabled = true;
btnSettings.Enabled = true;

View File

@@ -36,6 +36,7 @@ namespace osrepodbmgr
{
Core.Settings.LoadSettings();
Context.CheckUnar();
Context.usableDotNetZip = true;
Application.Init();
frmMain win = new frmMain();
win.Show();

View File

@@ -8,7 +8,7 @@ namespace Stetic
internal static void Initialize(Gtk.Widget iconRenderer)
{
if ((Stetic.Gui.initialized == false))
if((Stetic.Gui.initialized == false))
{
Stetic.Gui.initialized = true;
}
@@ -20,7 +20,7 @@ namespace Stetic
public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size)
{
Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
if ((res != null))
if((res != null))
{
return res;
}
@@ -33,9 +33,9 @@ namespace Stetic
{
return Gtk.IconTheme.Default.LoadIcon(name, sz, 0);
}
catch (System.Exception)
catch(System.Exception)
{
if ((name != "gtk-missing-image"))
if((name != "gtk-missing-image"))
{
return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size);
}