Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (!obj.GetType().Equals(this.GetType()))
            {
                return(false);
            }

            UOPPairData objPair = (UOPPairData)obj;

            return(objPair.First.Equals(this.First) && objPair.Second.Equals(this.Second));
        }
Ejemplo n.º 2
0
        public UopPatchError Replace(string sWhat, UOPPairData upData, bool bUncompressed)
        {
            if (upData == null)
            {
                return UopPatchError.IndexBlockError;
            }

            if (( sWhat == null ) || (!File.Exists(sWhat)))
            {
                return UopPatchError.FileError;
            }

            byte[] fileContent = null;
            using (FileStream fsToParse = new FileStream(sWhat, FileMode.Open))
            {
                using (BinaryReader brToParse = new BinaryReader(fsToParse))
                {
                    long fSize = fsToParse.Seek(0, SeekOrigin.End);
                    fileContent = new byte[fSize];
                    fsToParse.Seek(0, SeekOrigin.Begin);
                    fileContent = brToParse.ReadBytes((int)fSize);
                }
            }

            byte[] compressedStream = null;
            int iDestLength = -1;

            if (bUncompressed)
            {
                compressedStream = fileContent;
                iDestLength = fileContent.Length;
            }
            else
            {
                compressedStream = new byte[(int)Compressor.CompressBound((ulong)(fileContent.Length))];
                iDestLength = compressedStream.Length;
                if (ZLibError.Okay != Compressor.Compress(compressedStream, ref iDestLength, fileContent, fileContent.Length))
                {
                    GC.Collect();
                    return UopPatchError.CompressionError;
                }
            }

            if ((compressedStream == null) || (iDestLength == -1) || (bUncompressed && (compressedStream.Length != iDestLength)))
            {
                GC.Collect();
                return UopPatchError.BufferError;
            }

            bool bResultReplace = upData.ReplaceData(compressedStream, (uint)(iDestLength), (uint)(fileContent.Length));

            GC.Collect();
            return bResultReplace ? UopPatchError.Okay : UopPatchError.ReplaceError;
        }
Ejemplo n.º 3
0
 public void Delete(UOPPairData toDelete)
 {
     foreach (UOPIndexBlockHeader ibhCurrent in UopFile.m_Content)
     {
         for (int i = 0; i < ibhCurrent.m_ListData.Count; i++)
         {
             if (toDelete.Equals(ibhCurrent.m_ListData[i]))
             {
                 ibhCurrent.m_ListData.RemoveAt(i);
             }
         }
     }
 }
Ejemplo n.º 4
0
        private System.Collections.Hashtable AddData(UOPPairData pData, bool unCompressed)
        {
            this.txt_pnUopHeaderAndData_Data.Tag = null;

            if (this.oPatchDlgUopopen.ShowDialog(this) == DialogResult.OK)
            {
                System.Collections.Hashtable htTosend = new System.Collections.Hashtable();
                htTosend.Add("file", this.oPatchDlgUopopen.FileName);
                htTosend.Add("uncompressed", unCompressed);

                return htTosend;
            }

            return null;
        }