Exemplo n.º 1
0
        public static string PathToCoName(string path, string root)
        {
            path = FileTools.ChangeRoot(path, root);
            path = Path.Combine(
                Path.GetDirectoryName(path),
                StringTools.GetIsland(Path.GetFileName(path), ".").Left
                );
            string coName = path.Replace('\\', '_');

            return(coName);
        }
Exemplo n.º 2
0
        public static string PathToCoName(string path, string root)
        {
            path = FileTools.ChangeRoot(path, root);
            path = Path.Combine(
                Path.GetDirectoryName(path),
                StringTools.GetIsland(Path.GetFileName(path), ".").Left
                );
            string coName = path.Replace('\\', '_');

            if (IsFairName(coName) == false)
            {
                throw new Exception("不正なパスです。");
            }

            return(coName);
        }
Exemplo n.º 3
0
        private void Perform_02(string inputDir, string outputDir, bool outputOverwriteMode)
        {
            // 環境のチェック
            {
                if (File.Exists(Consts.FFMPEG_FILE) == false)
                {
                    throw new Exception("no ffmpeg.exe");
                }

                if (File.Exists(Consts.MASTER_FILE) == false)
                {
                    throw new Exception("no Master.exe");
                }

                if (File.Exists(Consts.wavCsv_FILE) == false)
                {
                    throw new Exception("no wavCsv.exe");
                }

                if (File.Exists(Consts.ImgTools_FILE) == false)
                {
                    throw new Exception("no ImgTools.exe");
                }

                {
                    string file = @".\ConvGenVideo.exe";

                    if (File.Exists(file) == false)
                    {
                        file = @"..\..\..\..\ConvGenVideo\ConvGenVideo\ConvGenVideo\bin\Release\ConvGenVideo.exe";                         // Dev-Env

                        if (File.Exists(file) == false)
                        {
                            throw new Exception("no ConvGenVideo.exe");
                        }
                    }
                    Ground.I.ConvGenVideoFile = file;
                }
            }

            Ground.I.Logger.Stat("<1 " + inputDir);
            Ground.I.Logger.Stat(">1 " + outputDir);

            inputDir  = FileTools.MakeFullPath(inputDir);
            outputDir = FileTools.MakeFullPath(outputDir);

            Ground.I.Logger.Stat("<2 " + inputDir);
            Ground.I.Logger.Stat(">2 " + outputDir);

            Ground.I.Logger.Stat("outputOverwriteMode: " + outputOverwriteMode);

            // memo: 出力フォルダが入力フォルダと同じ場合がある。

            if (Directory.Exists(inputDir) == false)
            {
                throw new ArgumentException("no inputDir: " + inputDir);
            }

            if (Directory.Exists(outputDir) == false)
            {
                throw new ArgumentException("no outputDir: " + outputDir);
            }

            string[] files = Directory.GetFiles(inputDir, "*", SearchOption.AllDirectories);

            files = files.Select(v => FileTools.ChangeRoot(v, inputDir)).ToArray();

            Ground.I.CmProgressRate.Clear();
            Ground.I.CmReport.Clear();

            for (int index = 0; index < files.Length; index++)
            {
                string file = files[index];

                {
                    double rate     = (index + 0.5) / files.Length;
                    string strRate  = rate.ToString("F9");
                    byte[] bStrRate = Encoding.ASCII.GetBytes(strRate);

                    Ground.I.CmProgressRate.Send(bStrRate);
                }

                try
                {
                    Ground.I.Logger.Stat("ファイル:" + file);

                    new ConvFileMain()
                    {
                        InputDir            = inputDir,
                        OutputDir           = outputDir,
                        OutputOverwriteMode = outputOverwriteMode,
                        PresumeAudioRelFile = file,
                    }
                    .Perform();

                    Ground.I.Logger.Stat("成功");
                }
                catch (Cancelled)
                {
                    Ground.I.Logger.Stat("中止・ユーザーによるキャンセル");

                    Ground.I.EvMessage_UserCancelled.Set();
                    break;
                }
                catch (Exception e)
                {
                    Ground.I.Logger.Stat("失敗:" + e);
                }
            }
        }
Exemplo n.º 4
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        /// <summary>
        /// <para>ファイルリストを取得する。</para>
        /// <para>ソート済み</para>
        /// <para>'_' で始まるファイルの除去済み</para>
        /// </summary>
        /// <returns>ファイルリスト</returns>
        public static IEnumerable <string> GetFiles()
        {
            IEnumerable <string> files;

            if (ReleaseMode)
            {
                files = File2ResInfo.Keys;
            }
            else
            {
                files = EnumerableTools.Join(new IEnumerable <string>[]
                {
                    Directory.GetFiles(DDConsts.ResourceDir_01, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir_01)),
                    Directory.GetFiles(DDConsts.ResourceDir_02, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir_02)),
                });

                // '_' で始まるファイルの除去
                // makeDDResourceFile は '_' で始まるファイルを含めない。
                files = files.Where(file => Path.GetFileName(file)[0] != '_');
            }

            // ソート
            // makeDDResourceFile はファイルリストを sortJLinesICase している。
            // ここでソートする必要は無いが、戻り値に統一性を持たせるため(毎回ファイルの並びが違うということのないように)ソートしておく。
            files = EnumerableTools.Sort(files, StringTools.CompIgnoreCase);

            return(files);
        }
Exemplo n.º 5
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        /// <summary>
        /// ファイルリストを取得する。
        /// ソート済み
        /// '_' で始まるファイルの除去済み
        /// </summary>
        /// <returns>ファイルリスト</returns>
        public static IEnumerable <string> GetFiles()
        {
            IEnumerable <string> files;

            if (ReleaseMode)
            {
                files = File2ResInfo.Keys;
            }
            else
            {
                files = Directory.GetFiles(DDConsts.ResourceDir, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir));

                // Sort
                {
                    List <string> tmp = files.ToList();
                    tmp.Sort(StringTools.CompIgnoreCase);
                    files = tmp;
                }

                // memo: makeDDResourceFile はファイルリストを sortJLinesICase してる。
            }
            return(files.Where(file => Path.GetFileName(file)[0] != '_'));

            // memo: makeDDResourceFile はファイルリストを _index として保存するので、Where はどっちでもやっておく。
        }
Exemplo n.º 6
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        /// <summary>
        /// <para>ファイルリストを取得する。</para>
        /// <para>ソート済み</para>
        /// <para>'_' で始まるファイルの除去済み</para>
        /// </summary>
        /// <returns>ファイルリスト</returns>
        public static IEnumerable <string> GetFiles()
        {
            IEnumerable <string> files;

            if (ReleaseMode)
            {
                files = File2ResInfo.Keys;
            }
            else
            {
                files = Directory.GetFiles(DDConsts.ResourceDir, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir));
            }

            // '_' で始まるファイルの除去
            // makeDDResourceFile はファイルリストを _index として保存するので、どちらの場合でも Where を行わなければならない。
            files = files.Where(file => Path.GetFileName(file)[0] != '_');

            // ソート
            // makeDDResourceFile はファイルリストを sortJLinesICase してる。
            files = EnumerableTools.Sort(files, StringTools.CompIgnoreCase);

            return(files);
        }
Exemplo n.º 7
0
        private void AddFile(string file, string dropRootDir = null)
        {
            if (Ground.I.IgnoreBeginDot && Path.GetFileName(file).StartsWith("."))
            {
                ProcMain.WriteLog("半角ピリオドで始まるファイルは無視します。⇒ " + file);
                return;
            }
            if (Ground.I.Config.AudioInfoMax <= this.MainSheet.RowCount + this.AddedInfos.Count)
            {
                throw new Exception("ファイルが多すぎます。");
            }

            if (Ground.I.ImageExtensions.IsImageFile(file))
            {
                int addImageFileMax = Ground.I.Config.AudioInfoMax;                 // 代用

                if (addImageFileMax <= this.AddedImageFiles.Count)
                {
                    throw new Exception("画像ファイルが多すぎます。");
                }

                this.AddedImageFiles.Add(file);
                return;
            }
            AudioInfo info;

            try
            {
                if (File.Exists(file) == false)
                {
                    throw new Exception("no file");
                }

                file = FileTools.MakeFullPath(file);

                if (Ground.I.AudioExtensions.IsAudioFile(file) == false)
                {
                    ProcMain.WriteLog("音楽ファイルではないので追加しません。⇒ " + file);
                    return;
                }
                this.AddedImageFileRejected = true;

                if (Ground.I.じ音楽ファイルを追加させない)
                {
                    bool known = this.KnownAudioFiles.Add(file) == false;
                    //bool known = this.MS_GetRowIndex(row => StringTools.EqualsIgnoreCase(this.MS_GetRow(row.Index).AudioFile, file)) != -1; // old 遅い

                    if (known)
                    {
                        ProcMain.WriteLog("音楽ファイルは重複しています。⇒ " + file);
                        return;
                    }
                }
                string imgFile = Ground.I.DefaultImageFile;

                if (Ground.I.UseSameNameImageFile)
                {
                    string sameNameImgFile = this.TryGetSameNameImageFile(file);

                    if (sameNameImgFile != null)
                    {
                        imgFile = sameNameImgFile;
                    }
                }
                string wFile;

                if (dropRootDir == null)
                {
                    wFile = Path.Combine(Ground.I.OutputDir, Path.GetFileName(file));
                }
                else
                {
                    wFile = FileTools.ChangeRoot(file, dropRootDir, Ground.I.OutputDir);
                }

                wFile = Path.Combine(Path.GetDirectoryName(wFile), Path.GetFileNameWithoutExtension(wFile)) + Consts.MOVIE_EXT;

                info = new AudioInfo()
                {
                    AudioFile = file,
                    ImageFile = imgFile,
                    MovieFile = wFile,
                };
            }
            catch (Exception e)
            {
                ProcMain.WriteLog(e);

                info = new AudioInfo()
                {
                    Status       = AudioInfo.Status_e.ERROR,
                    ErrorMessage = e.Message,
                    AudioFile    = file,
                };
            }
            this.AddedInfos.Add(info);
        }