Esempio n. 1
0
        public bool Build(string outputDir, string fileName)
        {
            var builder = new FileHashDatabaseBuilder
                          (
                folder: m_dataSourcePath,
                pattern: new string[]
            {
                "(.*?).awb$", "(.*?).acb$",
            }
                          );

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }
            var outputPath   = Path.Combine(outputDir, fileName);
            var fileHashList = builder.Build();
            var table        = CreateTable(fileHashList);
            var isWriteTable = SoundFileDatabase.Write(outputPath, table);

            if (!isWriteTable)
            {
                return(false);
            }

            return(DoPostBuild(outputDir, fileHashList, SoundFileDatabase.Read(outputPath)));
        }
Esempio n. 2
0
        protected override bool DoPostBuild(
            string outputDir,
            Dictionary <string, FileHashDatabaseBuilder.FileHashData> fileHashList,
            SoundFileDatabase table
            )
        {
            //	キューシート名のグループを作成
            var cueSheetGroup = fileHashList
                                .GroupBy(c => Path.GetFileNameWithoutExtension(c.Key))
                                .ToArray();

            try
            {
                foreach (var g in cueSheetGroup)
                {
                    var cueSheet = g.Key;
                    var item     = table.Find(cueSheet);
                    // 基ファイル
                    var acb       = g.FirstOrDefault(c => c.Key.Contains(".acb"));
                    var acbExport = Path.Combine(outputDir, item.Acb.Path).ToConvertDelimiter();
                    var dir       = Path.GetDirectoryName(acbExport);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    // コピー
                    acb.Value.FileInfo.CopyTo(acbExport, true);
                    if (!item.HasAwb())
                    {
                        continue;
                    }
                    var awb       = g.FirstOrDefault(c => c.Key.Contains(".awb"));
                    var awbExport = Path.Combine(outputDir, item.Awb.Path).ToConvertDelimiter();
                    dir = Path.GetDirectoryName(awbExport);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    // コピー
                    awb.Value.FileInfo.CopyTo(awbExport, true);
                }
            }
            catch
            {
                throw;
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// 作成
        /// </summary>
        private SoundFileDatabase CreateTable(
            Dictionary <string, FileHashDatabaseBuilder.FileHashData> fileHashList
            )
        {
            var ruleList = m_settings.CreateSettings();
            var table    = new SoundFileDatabase();

            //	拡張子を外して、キューシート名の一覧に
            var cueSheetList = fileHashList
                               .Keys
                               .Select(c => Path.GetFileNameWithoutExtension(c))
                               .Distinct()
                               .ToArray();
            //	キューシート名のグループを作成
            var cueSheetGroup = fileHashList
                                .GroupBy(c => Path.GetFileNameWithoutExtension(c.Key))
                                .ToArray();

            //	キューシート名を使ってデータを作成する
            foreach (var cueSheetName in cueSheetList)
            {
                //	同じキューシートの要素
                var group = cueSheetGroup.FirstOrDefault(c => c.Key == cueSheetName);
                Debug.Assert(group.Count() >= 0);
                Debug.Assert(group.Count() < 3);

                //	acb/awbファイルを取得
                var acbFile = group.FirstOrDefault(c => c.Key.Contains("acb"));
                var awbFile = group.FirstOrDefault(c => c.Key.Contains("awb"));
                var rule    = ruleList.Where(c => c.Filter.IsMatch(string.Empty, acbFile.Key))
                              .OrderBy(c => c.Priority)
                              .LastOrDefault();
                var labels = rule?.Labels ?? new string[0];

                var dirPath = Path.GetDirectoryName(acbFile.Key);
                var data    = _ToData(dirPath, cueSheetName, labels, acbFile.Value, awbFile.Value);

                table.Add(dirPath, data);
            }

            return(table);
        }
Esempio n. 4
0
 protected virtual bool DoPostBuild(string outputDir, Dictionary <string, FileHashDatabaseBuilder.FileHashData> fileHashList, SoundFileDatabase table) => true;