Package emissary.util

Class UnixFile


  • public class UnixFile
    extends Object
    • Constructor Detail

      • UnixFile

        public UnixFile​(File magicFile)
                 throws IOException
        Constructor to load instance using the specified File. If the specified file is invalid, an exception will be thrown when attempting utilize the execute method.
        Parameters:
        magicFile - the File containing magic number entries
        Throws:
        IOException
      • UnixFile

        public UnixFile​(File magicFile,
                        boolean swallowParseException)
                 throws IOException
        Constructor to load instance using the specified File. If the specified file is invalid, an exception will be thrown when attempting utilize the execute method.
        Parameters:
        magicFile - the File containing magic number entries
        swallowParseException - should we swallow Ignorable ParseException or bubble them up
        Throws:
        IOException
      • UnixFile

        public UnixFile​(List<String> magicPaths)
                 throws IOException
        Load multiple magic files into one identification engine
        Parameters:
        magicPaths - the String names of magic files to load
        Throws:
        IOException
      • UnixFile

        public UnixFile​(List<String> magicPaths,
                        boolean swallowParseException)
                 throws IOException
        Load multiple magic files into one identification engine
        Parameters:
        magicPaths - the String names of magic files to load
        swallowParseException - should we swallow Ignorable ParseException or bubble them up
        Throws:
        IOException
    • Method Detail

      • magicEntryCount

        public int magicEntryCount()
      • execute

        public String execute​(@Nullable
                              byte[] bytes)
                       throws IOException
        Behaves just like the UNIX file command. First performs a magic number test, then an ascii or binary file test. This is also the same as calling evaluateByMagicNumber (bytes : byte[]) and then calling evaluateBinaryProperty (bytes : byte[])
        Throws:
        IOException
      • evaluateBinaryProperty

        public static String evaluateBinaryProperty​(@Nullable
                                                    byte[] bytes)
        Statically tests a byte array to determine if the file representation can be of type ASCII or is binary. Simply checks each byte value to be less then greater/equal then 127.
      • evaluateByMagicNumber

        public String evaluateByMagicNumber​(byte[] bytes)
                                     throws IOException
        Evaluates the byte array against the collection of Magic numbers
        Throws:
        IOException