Exemple #1
0
        /// <summary>
        /// Initializes a new Instance from <paramref name="fileName"/>.
        /// </summary>
        /// <param name="fileName">Path to .uop file.</param>
        public MythicPackage(string fileName)
        {
            using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    int index = 0;

                    m_FileInfo = new FileInfo(fileName);
                    m_Header   = new MythicPackageHeader(reader);

                    stream.Seek(m_Header.StartAddress, SeekOrigin.Begin);

                    MythicPackageBlock block;

                    do
                    {
                        block        = new MythicPackageBlock(reader, this);
                        block.Index  = index++;
                        block.Parent = this;

                        m_Blocks.Add(block);
                    }while (stream.Seek(block.NextBlock, SeekOrigin.Begin) != 0);
                }
            }
        }
        /// <summary>
        /// Initializes a new Instance from <paramref name="fileName"/>.
        /// </summary>
        /// <param name="fileName">Path to .uop file.</param>
        public MythicPackage(string fileName)
        {
            // if the file doesn't exist, throw an exception
            if (!File.Exists(fileName))
            {
                throw new Exception(string.Format("Cannot find {0}!", Path.GetFileName(fileName)));
            }

            // open the uop file
            using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    // get the file info for the UOP file
                    FileInfo = new FileInfo(fileName);

                    // get the file header
                    Header = new MythicPackageHeader(reader);

                    // move to the starting point to start reading the blocks
                    stream.Seek((long)Header.StartAddress, SeekOrigin.Begin);

                    // initialize the block variable
                    MythicPackageBlock block;

                    do // load the block
                    {
                        block = new MythicPackageBlock(reader, this);
                    }
                    // keep loading until we have a next block address
                    while (stream.Seek(block.NextBlock, SeekOrigin.Begin) != 0);
                }
        }
        /// <summary>
        /// Initializes a new instance of Mythic Package File.
        /// <param name="version">Version of the file.</param>
        /// </summary>
        public MythicPackage(int version)
        {
            // create the header
            Header = new MythicPackageHeader(version);

            // set the modified and new flag
            Added    = true;
            Modified = true;
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of Mythic Package File.
 /// <param name="version">Version of the file.</param>
 /// </summary>
 public MythicPackage(int version)
 {
     m_Header = new MythicPackageHeader(version);
 }