mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Properly detect universal binaries when packing .app bundles (#179)
This commit is contained in:
@@ -7,7 +7,11 @@ public class BinDetect
|
|||||||
MH_MAGIC = 0xfeedface,
|
MH_MAGIC = 0xfeedface,
|
||||||
MH_CIGAM = 0xcefaedfe,
|
MH_CIGAM = 0xcefaedfe,
|
||||||
MH_MAGIC_64 = 0xfeedfacf,
|
MH_MAGIC_64 = 0xfeedfacf,
|
||||||
MH_CIGAM_64 = 0xcffaedfe
|
MH_CIGAM_64 = 0xcffaedfe,
|
||||||
|
// https://developer.apple.com/documentation/kernel/fat_header/1558632-magic/
|
||||||
|
// https://opensource.apple.com/source/file/file-80.40.2/file/magic/Magdir/cafebabe.auto.html
|
||||||
|
FAT_MAGIC = 0xcafebabe,
|
||||||
|
FAT_CIGAM = 0xbebafeca,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsMachOImage(string filePath)
|
public static bool IsMachOImage(string filePath)
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
namespace Velopack.Packaging;
|
|
||||||
|
|
||||||
public class MachO
|
|
||||||
{
|
|
||||||
private enum MagicMachO : uint
|
|
||||||
{
|
|
||||||
MH_MAGIC = 0xfeedface,
|
|
||||||
MH_CIGAM = 0xcefaedfe,
|
|
||||||
MH_MAGIC_64 = 0xfeedfacf,
|
|
||||||
MH_CIGAM_64 = 0xcffaedfe,
|
|
||||||
// https://developer.apple.com/documentation/kernel/fat_header/1558632-magic/
|
|
||||||
// https://opensource.apple.com/source/file/file-80.40.2/file/magic/Magdir/cafebabe.auto.html
|
|
||||||
FAT_MAGIC = 0xcafebabe,
|
|
||||||
FAT_CIGAM = 0xbebafeca,
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsMachOImage(string filePath)
|
|
||||||
{
|
|
||||||
using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath))) {
|
|
||||||
if (reader.BaseStream.Length < 256) // Header size
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint magic = reader.ReadUInt32();
|
|
||||||
return Enum.IsDefined(typeof(MagicMachO), magic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user