public void FixPath(int depth = 0) { WorkDir = (WorkDir.EndsWith("/") || WorkDir.EndsWith("\\")) ? WorkDir.Substring(0, WorkDir.Length - 1) : WorkDir; Path = FullPath.Replace(WorkDir + "/", "").Replace(WorkDir + "\\", ""); Replace = !isDir ? (System.IO.Path.GetExtension(FullPath).ToLowerEnglish().EndsWith("html") ? ("/" + Path.Substring(0, Path.Length - System.IO.Path.GetExtension(FullPath).Length).Replace("\\", "/")) : ("/" + Path.Replace("\\", "/"))) : "/" + Path.Replace("\\", "/"); string x = string.Empty; if (depth == 0) { x = "./"; } else if (depth > 0) { for (int i = 0; i < depth; i++) { x += "../"; } } Path = x + Path.Replace("\\", "/") + (!isDir ? (!Path.EndsWith(System.IO.Path.GetExtension(FullPath)) ? System.IO.Path.GetExtension(FullPath) : "") : "/index.html"); }
public override IEnumerable <Image> LoadImages() { var imagePaths = GetAllImagePathsInFolder(WorkDir, LegalImageExtensions); var trueLabelsByImageName = !TagInfoAvailable ? null : ReadTrueLabels(WorkDir + (WorkDir.EndsWith(@"\") ? string.Empty : @"\") + MetaInfoFileName); foreach (var imagePath in imagePaths) { var fileName = imagePath.Split('\\').Last(); var tagNames = trueLabelsByImageName != null && trueLabelsByImageName.ContainsKey(fileName) ? trueLabelsByImageName[fileName].ToList() : Enumerable.Empty <string>().ToList(); if (TagFilterEnabled && TagInfoAvailable) { tagNames = tagNames.Where(AllowedTagNames.Contains).ToList(); if (tagNames.Count == 0) { continue; } } yield return(new Image { Path = imagePath, TagNames = tagNames }); } }