/// <summary>
        /// Replaces this file with another.
        /// </summary>
        /// <param name="fileName">Path to the file on HD.</param>
        /// <param name="packageFolder">Relative folder within KR.</param>
        /// <param name="flag">Compression type.</param>
        public void Replace(string fileName, string packageFolder, CompressionFlag flag)
        {
            m_FileName        = Path.Combine(packageFolder, Path.GetFileName(fileName)).ToLower();
            m_FileHash        = HashDictionary.HashFileName(m_FileName);
            m_SourceFileName  = fileName;
            m_Compression     = flag;
            m_DataBlockLength = 0;
            m_DataBlockHash   = 0;

            Modified = true;
        }
        /// <summary>
        /// Search the exact file name inside the UOP file
        /// </summary>
        /// <param name="fileName">EXACT file name to search</param>
        /// <returns>Index of the <see cref="Mythic.Package.MythicPackageFile"/> in <see cref="Mythic.Package.MythicPackageBlock.Files"/> table.</returns>
        public SearchResult SearchExactFileName(string fileName)
        {
            foreach (MythicPackageBlock block in m_Blocks)
            {
                foreach (MythicPackageFile file in block.Files)
                {
                    if (file.FileHash == HashDictionary.HashFileName(fileName))
                    {
                        return(new SearchResult(block.Index, file.Index));
                    }
                }
            }

            return(SearchResult.NotFound);
        }
        /// <summary>
        /// Search the exact file name inside the UOP file
        /// </summary>
        /// <param name="fileName">EXACT file name to search</param>
        /// <returns>Index of the <see cref="MythicPackageFile"/> in <see cref="MythicPackageBlock.Files"/> table.</returns>
        public SearchResult SearchExactFileName(string fileName)
        {
            // search for the exact file name
            MythicPackageFile found = (from b in Blocks
                                       from f in b.Files
                                       where f.FileHash == HashDictionary.HashFileName(fileName)
                                       select f).FirstOrDefault();

            // did we find the file?
            if (found != null)
            {
                return(new SearchResult(found.Parent.Index, found.Index, HashDictionary.AddedFilenames.Contains(found.FileHash), found));
            }

            // if we got here, we found nothing
            return(SearchResult.NotFound);
        }
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="fileName">Absolute path to the file on HD.</param>
        /// <param name="innerFolder">Relative folder within KR (destination).</param>
        /// <param name="flag">Compression type.</param>
        public MythicPackageFile(string fileName, string innerFolder, CompressionFlag flag)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("fileName");
            }

            m_FileName = Path.Combine(innerFolder, Path.GetFileName(fileName)).ToLower();

            if (m_FileName.StartsWith("\\") || m_FileName.StartsWith("/"))
            {
                m_FileName = m_FileName.Substring(1);
            }

            m_FileName        = m_FileName.Replace('\\', '/');
            m_FileHash        = HashDictionary.HashFileName(m_FileName);
            m_SourceFileName  = fileName;
            m_Compression     = flag;
            m_DataBlockLength = 0;
            m_DataBlockHash   = 0;
        }