Exemple #1
0
        public void GetDatFileChecksums(
            ref Crc32 pChecksum,
            ref CryptoStream pMd5CryptoStream,
            ref CryptoStream pSha1CryptoStream)
        {
            using (FileStream fs = File.OpenRead(this.filePath))
            {
                // Reserved Section
                ChecksumUtil.AddChunkToChecksum(
                    fs,
                    (int)RESERVED_SECTION_OFFSET,
                    (int)this.reservedSectionLength,
                    ref pChecksum,
                    ref pMd5CryptoStream,
                    ref pSha1CryptoStream);

                // Compressed Program
                this.addDecompressedProgramChecksum(fs, ref pChecksum, ref pMd5CryptoStream, ref pSha1CryptoStream);
            }

            // Libs
            string[] libPaths = this.GetLibPathArray();

            foreach (string f in libPaths)
            {
                using (FileStream lfs = File.OpenRead(f))
                {
                    Xsf libXsf = new Xsf();
                    libXsf.Initialize(lfs, f);
                    libXsf.GetDatFileChecksums(ref pChecksum, ref pMd5CryptoStream, ref pSha1CryptoStream);
                    libXsf = null;
                }
            }
        }
Exemple #2
0
        public bool IsFileLibrary()
        {
            bool ret = false;

            FileStream fs;
            Type       formatType;
            Xsf        checkFile;
            ArrayList  libPathArray;

            string libDirectory = Path.GetDirectoryName(Path.GetFullPath(this.filePath));

            foreach (string f in Directory.GetFiles(libDirectory))
            {
                try
                {
                    fs         = File.OpenRead(f);
                    formatType = FormatUtil.getObjectType(fs);

                    if (formatType == this.GetType())
                    {
                        fs.Seek(0, SeekOrigin.Begin);
                        checkFile = new Xsf();
                        checkFile.Initialize(fs, f);
                        libPathArray = new ArrayList(checkFile.GetLibPathArray());

                        if (libPathArray.Contains(this.filePath.ToUpper()))
                        {
                            ret = true;
                            fs.Close();
                            fs.Dispose();
                            break;
                        }
                    }
                    fs.Close();
                    fs.Dispose();
                }
                catch (Exception)
                {
                    // Do nothing for now, if the file cannot be read than it cannot need a lib
                }
            }

            return(ret);
        }