Ejemplo n.º 1
0
 public UndoRedoSimisFile(string fileName, SimisProvider provider)
     : base(fileName, provider)
 {
     UndoBuffer = new Stack <SimisFileState>();
     RedoBuffer = new Stack <SimisFileState>();
     ResetUndo(new SimisTreeNode("<root>", ""), new SimisAce(0, 0, 0, 0, 0, "", "", new byte[44], new SimisAceChannel[0], new SimisAceImage[0], new byte[0], new byte[0]));
 }
Ejemplo n.º 2
0
        public static SimisReader FromStream(Stream stream, SimisProvider simisProvider, SimisJinxFormat jinxStreamFormat)
        {
            if (!stream.CanRead)
            {
                throw new ArgumentException("Stream must support reading.", "stream");
            }
            if (!stream.CanSeek)
            {
                throw new ArgumentException("Stream must support seeking.", "stream");
            }

            var reader    = SimisStreamReader.FromStream(stream);
            var position  = reader.BaseStream.Position;
            var signature = new String(reader.ReadChars(4));

            switch (signature)
            {
            case "JINX":
                return(new SimisJinxReader(reader, simisProvider, jinxStreamFormat));

            case "\x01\x00\x00\x00":
                return(new SimisAceReader(reader));

            default:
                throw new ReaderException(reader, reader.StreamIsBinary, (int)(reader.BaseStream.Position - position), "Signature '" + signature + "' is invalid.");
            }
        }
Ejemplo n.º 3
0
 public SimisJinxReader(SimisStreamReader reader, SimisProvider provider, SimisJinxFormat jinxStreamFormat)
     : base(reader)
 {
     JinxStreamFormat = jinxStreamFormat;
     SimisProvider    = provider;
     StreamLength     = reader.UncompressedLength;
     BlockEndOffsets  = new Stack <uint>();
     PendingTokens    = new Queue <SimisToken>();
     ReadStream(out JinxStreamIsBinary, ref JinxStreamFormat);
 }
Ejemplo n.º 4
0
 SimisFile(string fileName, bool streamIsBinary, bool streamIsCompressed, bool jinxStreamIsBinary, SimisJinxFormat jinxStreamFormat, SimisTreeNode tree, SimisAce ace, SimisProvider simisProvider)
 {
     FileName           = fileName;
     StreamIsBinary     = streamIsBinary;
     StreamIsCompressed = streamIsCompressed;
     JinxStreamIsBinary = jinxStreamIsBinary;
     JinxStreamFormat   = jinxStreamFormat;
     Tree          = tree;
     Ace           = ace;
     SimisProvider = simisProvider;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a <see cref="SimisFile"/> from a file.
 /// </summary>
 /// <param name="fileName">The file to read from.</param>
 /// <param name="simisProvider">A <see cref="SimisProvider"/> within which the appropriate <see cref="Bnf"/> for parsing can be found.</param>
 public SimisFile(string fileName, SimisProvider simisProvider)
 {
     FileName      = fileName;
     SimisProvider = simisProvider;
     try {
         using (var fileStream = File.OpenRead(FileName)) {
             using (var stream = new BufferedInMemoryStream(fileStream)) {
                 ReadStream(stream, out StreamIsBinary, out StreamIsCompressed, out JinxStreamIsBinary, out JinxStreamFormat, out Tree, out Ace);
             }
         }
     } catch (ReaderException e) {
         throw new FileException(FileName, e);
     }
 }
Ejemplo n.º 6
0
        public SimisJinxWriter(SimisStreamWriter writer, SimisProvider simisProvider, bool jinxStreamIsBinary, SimisJinxFormat jinxStreamFormat)
            : base(writer)
        {
            SimisProvider      = simisProvider;
            JinxStreamIsBinary = jinxStreamIsBinary;
            JinxStreamFormat   = jinxStreamFormat;

            TextBlocked = true;
            BlockStarts = new Stack <long>();

            if (JinxStreamIsBinary)
            {
                Writer.Write(("JINX0" + JinxStreamFormat.Format + "b______\r\n").ToCharArray());
            }
            else
            {
                Writer.Write(("JINX0" + JinxStreamFormat.Format + "t______\r\n\r\n").ToCharArray());
            }
        }
Ejemplo n.º 7
0
 public static SimisReader FromStream(Stream stream, SimisProvider simisProvider)
 {
     return(FromStream(stream, simisProvider, null));
 }
Ejemplo n.º 8
0
 public static SimisJinxWriter ToJinxStream(Stream stream, bool streamIsBinary, bool streamIsCompressed, SimisProvider simisProvider, bool jinxStreamIsBinary, SimisJinxFormat jinxStreamFormat)
 {
     if (!stream.CanWrite)
     {
         throw new ArgumentException("Stream must support writing.", "stream");
     }
     if (!stream.CanSeek)
     {
         throw new ArgumentException("Stream must support seeking.", "stream");
     }
     return(new SimisJinxWriter(SimisStreamWriter.ToStream(stream, streamIsBinary, streamIsCompressed), simisProvider, jinxStreamIsBinary, jinxStreamFormat));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a <see cref="SimisFile"/> from the component parts (JINX type).
 /// </summary>
 /// <param name="fileName">The file to write to.</param>
 /// <param name="streamIsBinary">The <see cref="bool"/> indicating whether the stream should use binary/ASCII or Unicode text (UTF-16) when written from this <see cref="SimisFile"/>.</param>
 /// <param name="streamIsCompressed">The <see cref="bool"/> indicating whether the stream should be compressed when written from this <see cref="SimisFile"/>.</param>
 /// <param name="jinxStreamIsBinary">The <see cref="bool"/> indicating whether the Jinx stream should use binary or text when written from this <see cref="SimisFile"/>.</param>
 /// <param name="jinxStreamFormat">The <see cref="SimisJinxFormat"/> for this <see cref="SimisFile"/>.</param>
 /// <param name="tree">The <see cref="SimisTreeNode"/> tree for this <see cref="SimisFile"/>.</param>
 /// <param name="simisProvider">A <see cref="SimisProvider"/> within which the appropriate <see cref="Bnf"/> for writing can be found.</param>
 public SimisFile(string fileName, bool streamIsBinary, bool streamIsCompressed, bool jinxStreamIsBinary, SimisJinxFormat jinxStreamFormat, SimisTreeNode tree, SimisProvider simisProvider)
     : this(fileName, streamIsBinary, streamIsCompressed, jinxStreamIsBinary, jinxStreamFormat, tree, null, simisProvider)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a <see cref="SimisFile"/> from a readable <see cref="Stream"/>.
 /// </summary>
 /// <param name="stream">The <see cref="Stream"/> to read from.</param>
 /// <param name="simisProvider">A <see cref="SimisProvider"/> within which the appropriate <see cref="Bnf"/> for parsing can be found.</param>
 public SimisFile(Stream stream, SimisProvider simisProvider)
 {
     FileName      = "";
     SimisProvider = simisProvider;
     ReadStream(stream, out StreamIsBinary, out StreamIsCompressed, out JinxStreamIsBinary, out JinxStreamFormat, out Tree, out Ace);
 }
Ejemplo n.º 11
0
 public MutableSimisFile(string fileName, SimisProvider simisProvider)
 {
     FileName      = fileName;
     SimisProvider = simisProvider;
 }
Ejemplo n.º 12
0
 public SimisJinxReader(SimisStreamReader reader, SimisProvider provider)
     : this(reader, provider, null)
 {
 }