Exemplo n.º 1
0
        /// <summary>
        /// いくつかの棋譜をRPMに変換。
        /// </summary>
        /// <returns>成功件数。</returns>
        public static int ConvertSomeFilesToRpm()
        {
            Trace.WriteLine($"{LogHelper.Stamp}ToRpm   : Start... Directory: {LocationMaster.EncodedDirectory.FullName}.");

            // 指定ディレクトリ以下のファイルをすべて取得する
            IEnumerable <string> eatingGoFiles =
                System.IO.Directory.EnumerateFiles(
                    LocationMaster.EncodedDirectory.FullName, "*", System.IO.SearchOption.AllDirectories);

            // 200件回す。
            var suceedCount = 0;

            foreach (string eatingGoFile in eatingGoFiles)
            {
                Trace.WriteLine($"{LogHelper.Stamp}ToRpm   : [{eatingGoFile}].");

                if (suceedCount > 199)
                {
                    break;
                }

                AbstractFile anyFile;
                switch (Path.GetExtension(eatingGoFile).ToUpper())
                {
                case ".CSA":
                    anyFile = new CsaFile(new TraceableFile(string.Empty), new TraceableFile(eatingGoFile));
                    break;

                case ".KIF":
                    anyFile = new KifFile(new TraceableFile(string.Empty), new TraceableFile(eatingGoFile));
                    break;

                default:
                    anyFile = new UnexpectedFile(new TraceableFile(string.Empty));
                    Rest++;
                    break;
                }

                // 棋譜をRPMに変換。
                if (anyFile.ConvertAnyFileToRpm())
                {
                    suceedCount++;
                }
            }

            Trace.WriteLine($"{LogHelper.Stamp}ToRpm   : End.");
            return(suceedCount);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 少し解凍。
        /// </summary>
        /// <returns>ループが回った回数。</returns>
        public static int ExpandLittleIt()
        {
            Trace.WriteLine($"{LogHelper.Stamp}Expand  : Start...");

            // 指定ディレクトリ以下のファイルをすべて取得する
            IEnumerable <string> expansionGoFiles =
                System.IO.Directory.EnumerateFiles(
                    LocationMaster.InputDirectory.FullName, "*", System.IO.SearchOption.AllDirectories);

            Rest = 0;

            // 圧縮ファイルを 3つ 解凍する
            var count = 0;

            foreach (string expansionGoFileFullName in expansionGoFiles)
            {
                var expansionGoFile = new TraceableFile(expansionGoFileFullName);

                if (count > 3)
                {
                    break;
                }

                AbstractFile anyFile;
                switch (Path.GetExtension(expansionGoFile.FullName).ToUpperInvariant())
                {
                case ".7Z":
                    anyFile = new SevenZipFile(expansionGoFile);
                    break;

                case ".CSA":
                    anyFile = new CsaFile(expansionGoFile, new TraceableFile(string.Empty));
                    break;

                case ".KIF":
                    anyFile = new KifFile(expansionGoFile, new TraceableFile(string.Empty));
                    break;

                case ".LZH":
                    anyFile = new LzhFile(expansionGoFile);
                    break;

                case ".TGZ":
                    anyFile = new TargzFile(expansionGoFile);
                    break;

                case ".ZIP":
                    anyFile = new ZipArchiveFile(expansionGoFile);
                    break;

                default:
                    anyFile = new UnexpectedFile(expansionGoFile);
                    Rest++;
                    break;
                }

                // 解凍する。
                if (anyFile.Expand())
                {
                }

                count++;
            }

            // Trace.WriteLine($"{LogHelper.Stamp}むり1: {Rest}");
            return(count);
        }