Ejemplo n.º 1
0
        /// <summary>
        /// Helper method for opening Frostbite binary file data inside of <see cref="TreeView"/>.
        /// </summary>
        /// <param name="treeView">The <see cref="TreeView"/> object to open data in.</param>
        /// <param name="path">The file to open for reading.</param>
        /// <param name="offset">Position to start reading in file.</param>
        public static void OpenFrostbiteBinaryFile(this TreeView treeView, string path, uint offset)
        {
            Entry    mainEntry     = SurfaceFile.CreateEntry(path, offset);
            TreeNode mainEntryNode = mainEntry.CreateTreeNode();

            // After adding mainEntryNode expands it to reveal data quicker
            treeView.Nodes.Add(mainEntryNode);
            treeView.Nodes[0].Expand();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads data from file to put into current <see cref="InitFS"/> object.
        /// </summary>
        /// <param name="path">The file to read from.</param>
        /// <exception cref="ArgumentException">Thrown if file does not exist in <paramref name="path"/>.</exception>
        private void ReadFromFile(string path)
        {
            if (!File.Exists(path))
            {
                throw new ArgumentException("Data does not point to valid file on system.", "path");
            }

            using var reader = new BinaryReader(File.OpenRead(path));

            this.Name          = Path.GetFileName(path);
            this.IsWin32       = SurfaceFile.IsHeaderPresent(reader);
            this.Keys          = this.IsWin32 ? reader.ReadBytes(SurfaceConstants.KeysLength) : SurfaceFile.GetBlankKeys;
            this.FileEntryList = (List <Entry>)SurfaceFile.CreateEntry(path, this.IsWin32).Data;
        }