Ejemplo n.º 1
0
        /// <summary>
        /// Function to open a chunked file within the stream.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This opens a Gorgon chunk file that exists within the <see cref="Stream"/> passed to the constructor of this object. Typically this would be in a <see cref="FileStream"/>, but any type of stream
        /// is valid and can contain a chunk file.
        /// </para>
        /// <para>
        /// If the this method is called and the file is already opened, then it will be closed and reopened.
        /// </para>
        /// <note type="Important">
        /// Always pair a call to <c>Open</c> with a call to <see cref="Close"/>, otherwise the file may become corrupted or the stream may not be updated to the correct position.
        /// </note>
        /// <note type="Important">
        /// When this file is opened for <i>reading</i>, then validation is performed on the file header to ensure that it is a genuine GCFF file. If it is not, then an exception will be thrown
        /// detailing what's wrong with the header.
        /// </note>
        /// </remarks>
        /// <exception cref="GorgonException">Thrown when the chunk file format header ID does not match when reading.
        /// <para>-or-</para>
        /// <para>Thrown when application specific header ID in the file was not found in the list passed to the constructor when reading.</para>
        /// <para>-or-</para>
        /// <para>Thrown if the chunk file table offset is less than or equal to the size of the header when reading.</para>
        /// <para>-or-</para>
        /// <para>Thrown if the file size recorded in the header is less than the size of the header when reading.</para>
        /// </exception>
        public void Open()
        {
            if (IsOpen)
            {
                Close();
            }

            // Reset the stream position back to the beginning of the file.
            // This is a stream wrapper, so it'll be relative to the actual stream position.
            Stream.Position = 0;

            ChunkList.Clear();

            switch (Mode)
            {
            case ChunkFileMode.Read:
                ReadHeaderValidate();
                break;

            case ChunkFileMode.Write:
                WriteHeader();
                break;

            default:
                throw new ArgumentException(Resources.GOR_ERR_CHUNK_ILLEGAL_OPEN_MODE);
            }

            IsOpen = true;
        }
Ejemplo n.º 2
0
        // BLK Editor

        private void newToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            openVisibilityFile = null;
            ChunkList.Clear();
            numericCurrentChunk.Maximum = ChunkList.Count();
            labelChunkAmount.Text       = "Amount: " + ChunkList.Count();
            labelLoadedBLK.Text         = "No BLK loaded";
        }