Ejemplo n.º 1
0
        public mNode Read()
        {
            using var file = File.Open(FileName, FileMode.Open);
            Stream         = new BinaryStream(file, ByteConverter.Big);

            string magic = Stream.ReadString(4);

            if (magic == "Proj")
            {
                // Text version
                return(null);
            }
            else if (magic != "MPRJ")
            {
                Console.WriteLine($"Not a MPRJ Binary file.");
                return(null);
            }

            Version = (byte)Stream.DecodeBitsAndAdvance();
            if (Version != 0 && Version != 1)
            {
                Console.WriteLine($"Unsupported MPRJ Version {Version}.");
                return(null);
            }

            var rootPrjNode = new mNode();

            rootPrjNode.IsRoot = true; // For version 0
            if (Version == 1)
            {
                Stream.Position += 1; // Skip scope type
            }
            Console.WriteLine($"MPRJ Version: {Version}");
            rootPrjNode.Read(this);

            Stream.Dispose();

            return(rootPrjNode);
        }