public void RunHeaderTest(byte[] source, SwfCompression expectedCompression, byte expectedVersion, int expectedLength) { // use a memory stream for testing using (MemoryStream stream = new MemoryStream(source)) { SwfHeader header = SwfHeader.FromStream(stream); Assert.AreEqual(expectedCompression, header.Compression); Assert.AreEqual(expectedVersion, header.Version); Assert.AreEqual(expectedLength, header.FileLength); } }
public static int Main(string[] args) { bool preserveComments = false; // parse options passed in from command line OptionSet options = new OptionSet() { { "c|preserve-comments", "Try to preserve comments from ActionScript code in generated JavaScript code", v => preserveComments = v != null } }; List <string> extras; try { extras = options.Parse(args); } catch (OptionException e) { Console.Error.Write("unflash: "); Console.Error.WriteLine(e.Message); return(1); } // extras must have at least one instance: the file uri if (extras.Count == 0) { Console.Error.WriteLine("unflash: Please pass in the location of the SWF file as the first argument"); return(1); } // check to see if the file uri exists string fileUri = extras[0]; if (!File.Exists(fileUri)) { Console.Error.WriteLine(String.Format("unflash: Unable to find file {0}", fileUri)); return(1); } Console.WriteLine("Beginning file read..."); using (FileStream f = File.Open(fileUri, FileMode.Open)) Console.WriteLine(SwfHeader.FromStream(f)); return(0); }