Пример #1
0
        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);
            }
        }
Пример #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 IsMacExecutable_ForLinuxApp_ReturnsFalse()
 {
     Assert.IsFalse(MagicBytes.IsMacExecutable(_linuxApp));
 }
 public void IsMacExecutable_ForWindowsApp_ReturnsFalse()
 {
     Assert.IsFalse(MagicBytes.IsMacExecutable(_windowsApp));
 }
 public void IsMacExecutable_ForMacApp_ReturnsTrue()
 {
     Assert.IsTrue(MagicBytes.IsMacExecutable(_macApp));
 }