Click here to Skip to main content
15,896,522 members
Articles / General Programming / Threads

SimplePack Library

Rate me:
Please Sign up or sign in to vote.
4.93/5 (30 votes)
23 Nov 2010CPOL7 min read 73.1K   1.9K   97  
Simple way how to pack data into one file
using System;
using System.Xml.Serialization;
using SimplePack.Helper;

namespace SimplePack.Data
{
    ///<summary>
    /// FileArchive represent file structure in Archive hierarchical structure.
    ///</summary>
    [Serializable]
    public class FileArchive : ElementaryArchive
    {
        #region Properties

        private long startSeek;
        private uint checkSum;

        #endregion

        #region Constructors

        ///<summary>
        /// Default constructor.
        ///</summary>
        public FileArchive()
        {
            //necessary for xmlreader/writer
        }

        ///<summary>
        ///</summary>
        ///<param name="name">Name of file (with extension)</param>
        public FileArchive(string name)
            : this(name, null, null, 0, 0)
        {
        }

        ///<summary>
        ///</summary>
        ///<param name="name">Name of file (with extension)</param>
        ///<param name="fullPath">File's full path</param>
        ///<param name="parentDirectory">Parent directory to current file</param>
        ///<param name="length">Length of file</param>
        ///<param name="checkSum">CRC checksum</param>
        public FileArchive(string name, string fullPath, IArchiveStructure parentDirectory, long length, uint checkSum)
        {
            Name = name;
            FullPath = fullPath;
            ParentDirectory = parentDirectory;
            Length = length;
            CheckSum = checkSum;
        }

        #endregion

        #region Attributes

        ///<summary>
        /// Start position of file which is stored in Archive.
        ///</summary>
        [XmlAttribute]
        public long StartSeek
        {
            get { return startSeek; }
            set { startSeek = value; }
        }

        ///<summary>
        /// CRC checksum.
        ///</summary>
        [XmlAttribute]
        public uint CheckSum
        {
            get { return checkSum; }
            set { checkSum = value; }
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Slovakia Slovakia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions