void ProcessDirectoryOnlyMissing(ProcessDirectoryOrFileParams spec, IAbsoluteDirectoryPath directory) { var biKeys = directory.DirectoryInfo.EnumerateFiles("*.bikey", SearchOption.AllDirectories) .Select(x => new BiKeyFile(x)).ToArray(); var pboFiles = directory.DirectoryInfo.EnumerateFiles("*.pbo", SearchOption.AllDirectories); var signFiles = directory.DirectoryInfo.EnumerateFiles("*.bisign", SearchOption.AllDirectories) .Select(x => new BiSignFile(x)); var validSignfiles = signFiles.Where(s => biKeys.Any(k => MatchesKey(k, s))).ToArray(); var todoFiles = pboFiles.Where(f => !validSignfiles.Any(s => MatchesBiSign(s, f))) .ToArray(); if (todoFiles.Length <= 0) { return; } var biKeyP = GetKey(spec, directory); foreach (var f in todoFiles) { _biSigner.SignFile(f.FullName.ToAbsoluteFilePath(), biKeyP.PrivateFile, spec.RepackIfFailed); } }
void ProcessDirectory(ProcessDirectoryOrFileParams spec, IAbsoluteDirectoryPath directory) { if (spec.OnlyWhenMissing) { ProcessDirectoryOnlyMissing(spec, directory); return; } var biKeyPair = GetKey(spec, directory); _biSigner.SignFolder(directory, biKeyPair.PrivateFile, spec.RepackIfFailed); }
void ProcessDirectoryOrFile(ProcessDirectoryOrFileParams spec) { if (Directory.Exists(spec.Arg)) { ProcessDirectory(spec, spec.Arg.ToAbsoluteDirectoryPath()); return; } if (!File.Exists(spec.Arg)) throw new Exception("Cannot find {0}".FormatWith(spec.Arg)); ProcessFile(spec, spec.Arg.ToAbsoluteFilePath()); }
void ProcessDirectoryOrFile(ProcessDirectoryOrFileParams spec) { if (Directory.Exists(spec.Arg)) { ProcessDirectory(spec, spec.Arg.ToAbsoluteDirectoryPath()); return; } if (!File.Exists(spec.Arg)) { throw new Exception("Cannot find {0}".FormatWith(spec.Arg)); } ProcessFile(spec, spec.Arg.ToAbsoluteFilePath()); }
void ProcessFile(ProcessDirectoryOrFileParams spec, IAbsoluteFilePath filePath) { if (spec.OnlyWhenMissing && filePath.FileInfo.Directory.EnumerateFiles("*.bisign") .Any(s => MatchesBiSign(s.FullName, filePath.ToString()))) { return; } var biKeyPair = GetKey(spec, filePath.ParentDirectoryPath); _biSigner.SignFile(filePath, biKeyPair.PrivateFile, spec.RepackIfFailed); }
void ProcessDirectoryOnlyMissing(ProcessDirectoryOrFileParams spec, IAbsoluteDirectoryPath directory) { var biKeys = directory.DirectoryInfo.EnumerateFiles("*.bikey", SearchOption.AllDirectories) .Select(x => new BiKeyFile(x)).ToArray(); var pboFiles = directory.DirectoryInfo.EnumerateFiles("*.pbo", SearchOption.AllDirectories); var signFiles = directory.DirectoryInfo.EnumerateFiles("*.bisign", SearchOption.AllDirectories) .Select(x => new BiSignFile(x)); var validSignfiles = signFiles.Where(s => biKeys.Any(k => MatchesKey(k, s))).ToArray(); var todoFiles = pboFiles.Where(f => !validSignfiles.Any(s => MatchesBiSign(s, f))) .ToArray(); if (todoFiles.Length <= 0) return; var biKeyP = GetKey(spec, directory); foreach (var f in todoFiles) _biSigner.SignFile(f.FullName.ToAbsoluteFilePath(), biKeyP.PrivateFile, spec.RepackIfFailed); }
BiKeyPair GetKey(ProcessDirectoryOrFileParams spec, IAbsoluteDirectoryPath directory) => _biSigner.HandleKey(new BiSigner.HandleKeyParams(spec.KeyPath, spec.Prefix, spec.CopyKey, directory, spec.Key));
void ProcessFile(ProcessDirectoryOrFileParams spec, IAbsoluteFilePath filePath) { if (spec.OnlyWhenMissing && filePath.FileInfo.Directory.EnumerateFiles("*.bisign") .Any(s => MatchesBiSign(s.FullName, filePath.ToString()))) return; var biKeyPair = GetKey(spec, filePath.ParentDirectoryPath); _biSigner.SignFile(filePath, biKeyPair.PrivateFile, spec.RepackIfFailed); }