public static bool IsExecutable(string filePath, PlatformType platformType)
        {
            switch (platformType)
            {
            case PlatformType.Windows:
                return(filePath.EndsWith(".exe"));

            case PlatformType.OSX:
                return(MagicBytes.IsMacExecutable(filePath));

            case PlatformType.Linux:
                return(MagicBytes.IsLinuxExecutable(filePath));

            default:
                throw new ArgumentOutOfRangeException("platformType", platformType, null);
            }
        }
Exemple #2
0
        private bool IsExecutable(string filePath, PlatformType platformType)
        {
            switch (platformType)
            {
            case PlatformType.Unknown:
                throw new ArgumentException("Unknown");

            case PlatformType.Windows:
                throw new ArgumentException("Unsupported");

            case PlatformType.OSX:
                return(MagicBytes.IsMacExecutable(filePath));

            case PlatformType.Linux:
                return(MagicBytes.IsLinuxExecutable(filePath));

            default:
                throw new ArgumentOutOfRangeException("platformType", platformType, null);
            }
        }
 public void IsLinuxExecutable_ForLinuxApp_ReturnsTrue()
 {
     Assert.IsTrue(MagicBytes.IsLinuxExecutable(_linuxApp));
 }
 public void IsLinuxExecutable_ForWindowsApp_ReturnsFalse()
 {
     Assert.IsFalse(MagicBytes.IsLinuxExecutable(_windowsApp));
 }
 public void IsLinuxExecutable_ForMacApp_ReturnsFalse()
 {
     Assert.IsFalse(MagicBytes.IsLinuxExecutable(_macApp));
 }