Пример #1
0
        /// <summary>
        /// 作成
        /// </summary>
        private MovieFileDatabase CreateTable(
            Dictionary <string, FileHashDatabaseBuilder.FileHashData> fileHashList
            )
        {
            var ruleList = m_settings.CreateSettings();
            var table    = new MovieFileDatabase();

            foreach (var file in fileHashList)
            {
                var data = file.Value;
                var info = data.FileInfo;
                var path = data.Key;
                var key  = path.Replace(info.Extension, string.Empty);
                var size = info.Length;
                var hash = data.Hash;
                var rule = ruleList.Where(c => c.Filter.IsMatch(string.Empty, path))
                           .OrderBy(c => c.Priority)
                           .LastOrDefault();
                var labels = rule?.Labels ?? new string[0];
                // usmファイル情報を追加
                table.Add(new MovieFileData
                {
                    Key      = key,
                    Size     = size,
                    Hash     = hash,
                    Path     = path,
                    m_Labels = labels
                });
            }

            return(table);
        }
Пример #2
0
        public bool Build(string directoryPath, string fileName)
        {
            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            // ハッシュ値
            var builder = new FileHashDatabaseBuilder
                          (
                folder: directoryPath,
                pattern: new string[]
            {
                "(.*?).usm$",
            }
                          );
            var outputPath   = Path.Combine(directoryPath, fileName);
            var fileHashList = builder.Build();
            var table        = CreateTable(fileHashList);

            return(MovieFileDatabase.Write(outputPath, table));
        }