Esempio n. 1
0
        private static void AddZip(FileInfo f, DatDir thisDir)
        {
            Zip       zf1    = new Zip();
            ZipReturn result = zf1.ZipFileOpen(f.FullName, -1, true);

            if (result != ZipReturn.ZipGood)
            {
                return;
            }

            zCount += 1;
            if ((zf1.ZipStatus & ZipStatus.TrrntZip) == ZipStatus.TrrntZip)
            {
                tCount += 1;

                Console.WriteLine($"{zCount}   {tCount}    {cCount}");
            }

            else if (zf1.Filecomment != null && zf1.Filecomment.Length > 0)
            {
                string comments = ZipUtils.GetString(zf1.Filecomment);

                if (comments.Length > 13 && comments.Substring(0, 13) == "TORRENTZIPPED")
                {
                    tCount += 1;
                }
                else
                {
                    cCount += 1;
                    Console.WriteLine(f.FullName + "   " + zCount);
                    Console.WriteLine("------------------------");
                    Console.WriteLine(comments);
                }

                Console.WriteLine($"{zCount}   {tCount}    {cCount}");
            }
            //zf1.ZipStatus = ZipStatus.TrrntZip;

            //DatDir ZipDir = new DatDir(zf1.ZipStatus == ZipStatus.TrrntZip ? DatFileType.DirTorrentZip : DatFileType.DirRVZip)
            DatDir ZipDir = new DatDir(DatFileType.UnSet)
            {
                Name  = Path.GetFileNameWithoutExtension(f.Name),
                DGame = new DatGame()
            };

            ZipDir.DGame.Description = ZipDir.Name;
            thisDir.ChildAdd(ZipDir);



            FileScan fs = new FileScan();
            List <FileScan.FileResults> fr = fs.Scan(zf1, !quick, !quick);
            bool isTorrentZipDate          = true;

            for (int i = 0; i < fr.Count; i++)
            {
                if (fr[i].FileStatus != ZipReturn.ZipGood)
                {
                    Console.WriteLine("File Error :" + zf1.Filename(i) + " : " + fr[i].FileStatus);
                    continue;
                }

                DatFile df = new DatFile(DatFileType.UnSet)
                {
                    Name         = zf1.Filename(i),
                    Size         = fr[i].Size,
                    CRC          = fr[i].CRC,
                    SHA1         = fr[i].SHA1,
                    DateModified = new DateTime(zf1.LastModified(i)).ToString("yyyy/MM/dd HH:mm:ss"),
                    DateCreated  = zf1.Created(i) == null ? null : new DateTime((long)zf1.Created(i)).ToString("yyyy/MM/dd HH:mm:ss"),
                    DateAccessed = zf1.Accessed(i) == null ? null : new DateTime((long)zf1.Accessed(i)).ToString("yyyy/MM/dd HH:mm:ss")
                                   //df.MD5 = zf.MD5(i)
                };
                if (zf1.LastModified(i) != 629870671200000000)
                {
                    isTorrentZipDate = false;
                }

                ZipDir.ChildAdd(df);
            }
            zf1.ZipFileClose();
            if (isTorrentZipDate && ZipDir.DatFileType == DatFileType.DirRVZip)
            {
                ZipDir.DatFileType = DatFileType.DirTorrentZip;
            }

            if (ZipDir.DatFileType == DatFileType.DirTorrentZip)
            {
                DatSetCompressionType.SetZip(ZipDir);
                DatClean.RemoveUnNeededDirectoriesFromZip(ZipDir);
            }
        }