public TinfoilIndex Build(IEnumerable <Dir> dirs, TinfoilIndexType indexType, string?messageOfTheDay) { var tinfoilIndex = new TinfoilIndex { Success = messageOfTheDay, }; switch (indexType) { case TinfoilIndexType.Flatten: foreach (var dir in dirs) { AppendFlatten(dir, tinfoilIndex); } break; case TinfoilIndexType.Hierarchical: foreach (var dir in dirs) { AppendHierarchical(dir, tinfoilIndex); } break; default: throw new ArgumentOutOfRangeException(nameof(indexType), indexType, null); } return(tinfoilIndex); }
private void AppendFlatten(Dir dir, TinfoilIndex tinfoilIndex) { var urlCombiner = _urlCombinerFactory.Create(dir.CorrespondingUrl); var localDirPath = dir.Path; if (!Directory.Exists(localDirPath)) { return; } var filePaths = Directory.GetFiles(localDirPath, "*.*", SearchOption.AllDirectories); foreach (var filePath in filePaths) { if (!_fileFilter.IsFileAllowed(filePath)) { continue; } var relFilePath = filePath[localDirPath.Length..]; // SubString from dirPath.Length to the end
public TinfoilIndex Build(string directory, Uri correspondingUri, TinfoilIndexType indexType, string?messageOfTheDay) { var rooDirUri = correspondingUri.OriginalString.EndsWith('/') ? correspondingUri : new Uri(correspondingUri.OriginalString + "/"); var tinfoilIndex = new TinfoilIndex { Success = messageOfTheDay, }; switch (indexType) { case TinfoilIndexType.Flatten: var filePaths = Directory.GetFiles(directory, "*.*", SearchOption.AllDirectories); foreach (var filePath in filePaths) { if (!_fileFilter.IsFileAllowed(filePath)) { continue; } var relFilePath = filePath[directory.Length..];
public CacheData(DateTime creationTime, TinfoilIndex tinfoilIndex) { CreationTime = creationTime; TinfoilIndex = tinfoilIndex; }