.. да и вообще код сильно ориентирован на использование расшиений и функциональной парадигмы
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ff.links
{
static partial class Program
{
static IEnumerable<string> scan(this IEnumerable<string> ds)
{
var files = new List<string>();
foreach (var d in ds)
try { files.add2my(d.here()).add2my(d.subdirs()); }
catch (Exception e) { Console.WriteLine($"{pfx}Scan \"{d}\" - {e.Message}"); }
return files;
}
static List<string> add2my(this List<string> l, IEnumerable<string> r) { l.AddRange(r); return l; }
static IEnumerable<string> here(this string d) => Directory.EnumerateFiles(d).Where(f => f.isTarget());
static IEnumerable<string> subdirs(this string d) => Directory.EnumerateDirectories(d).Where(p => !p.isIgnored()).scan();
static void print(this string s, string pfx = "", string sfx = "") => Console.WriteLine(pfx + s + sfx);
static void print(this IEnumerable<string> sa, string pfx = "", string sfx = "") => sa.ToList().ForEach(s => s.print(pfx, sfx));
static bool isTarget(this string p) => targets.Contains(p.Split(backSlashDelimiter).Last());
static string[] targets => new string[] { ffBinary, ffProfileSign, fflConfig };
const string fflConfig = "ff.links.cfg.json";
const string ffBinary = "firefox.exe";
const string ffProfileSign = "compatibility.ini";
const string skipd = ".default";
static bool isIgnored(this string p) => ignored.Contains(p.Split(backSlashDelimiter, StringSplitOptions.RemoveEmptyEntries).Last());
static string[] ignored => new string[]
{
"TorBrowser", "Microsoft", "MICROSOFT", "WindowsApps", "Windows", "WINDOWS",
"ProgramData", "All Users", "Documents and Settings", //"Users",
"My Documents", "My Pictures", "My Music", "My Videos", "Application Data",
"Start Menu", "Local Settings", "Cookies", "NetHood", "PrintHood", "Recent", "SendTo", "Templates",
"CrashReports", "WindowsImageBackup", "System Volume Information", "$Recycle.Bin", "$RECYCLE.BIN",
"root", "Default User"
};
static char[] backSlashDelimiter = new char[] { backSlash };
const char backSlash = '\\';
static IEnumerable<string> fromRoot() => Environment.GetLogicalDrives().Where(p => !p.isIgnored());
static IEnumerable<string> fromSysDrive() { yield return @"c:\"; }
static IEnumerable<string> fromTypical()
{
var path = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\Mozilla Firefox";
yield return path;
int p;
if ((p=path.IndexOf(" (x86)")) >= 0)
yield return path = path.Remove(p, 6);
path = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\Mozilla\Firefox\Profiles";
yield return path;
}
}
}