public override async Task MainAsync(string[] arguments) { var solutionFiles = new List <string>(); if (arguments.Length > 1) { if (CurrentFileSystem.FileExists(arguments[1])) { solutionFiles.Add(arguments[1]); } } else { foreach (var file in CurrentFileSystem.GetFiles("./", "*.skysln", true)) { solutionFiles.Add(file); } } var progress = new ProgressReportToken(); for (int i = 0; i < solutionFiles.Count; i++) { var baseProgress = i / solutionFiles.Count; progress.Progress = baseProgress; using (var solution = await Solution.OpenProjectFile(solutionFiles[i], CurrentPluginManager)) { if (solution.CanBuild) { void onProgressChanged(object sender, ProgressReportedEventArgs e) { progress.Progress = baseProgress + (e.Progress / solutionFiles.Count); } solution.ProgressChanged += onProgressChanged; await solution.Build(); } else { Console.WriteLine(string.Format(Properties.Resources.Console_Build_SolutionNotBuildable, Path.GetFileName(solutionFiles[i]))); } } } }
string[] IFileSystem.GetFiles(string path, string searchPattern, bool topDirectoryOnly) { var searchPatternRegex = new Regex(GetFileSearchRegex(searchPattern), RegexOptions.Compiled | RegexOptions.IgnoreCase); var parts = GetPathParts(path); var output = new List <string>(); void addRomFsFiles(int partitionId) { var directory = "/" + GetRomFsDirectoryName(partitionId) + "/"; var currentDirectory = GetPartitionOrDefault(partitionId)?.RomFs?.Level3.RootDirectoryMetadataTable; for (int i = 1; i < parts.Length; i += 1) { currentDirectory = currentDirectory?.ChildDirectories.Where(x => string.Compare(x.Name, parts[i], true) == 0).FirstOrDefault(); directory += currentDirectory.Name + "/"; } if (currentDirectory != null) { IEnumerable <string> files; if (ReferenceEquals(currentDirectory, GetPartitionOrDefault(partitionId).RomFs.Level3.RootDirectoryMetadataTable)) { // The root RomFS directory doesn't contain files; those are located in the level 3 files = GetPartitionOrDefault(partitionId).RomFs.Level3.RootFiles .Where(f => searchPatternRegex.IsMatch(f.Name)) .Select(f => directory + f.Name); } else { files = currentDirectory.ChildFiles .Where(f => searchPatternRegex.IsMatch(f.Name)) .Select(f => directory + f.Name); } output.AddRange(files); if (!topDirectoryOnly) { foreach (var d in currentDirectory.ChildDirectories) { output.AddRange((this as IFileSystem).GetFiles(directory + d.Name + "/", searchPattern, topDirectoryOnly)); } } } } var dirName = parts[0].ToLower(); switch (dirName) { case "" when parts.Length == 1: if (!topDirectoryOnly) { for (int i = 0; i < Partitions.Length; i++) { if (Partitions[i].ExHeader != null) { var exheaderName = GetExHeaderFileName(i); if (!searchPatternRegex.IsMatch(exheaderName)) { output.Add(exheaderName); } } if (Partitions[i].ExeFs != null) { output.AddRange((this as IFileSystem).GetFiles("/" + GetExeFsDirectoryName(i), searchPattern, topDirectoryOnly)); } if (Partitions[i].RomFs != null) { output.AddRange((this as IFileSystem).GetFiles("/" + GetRomFsDirectoryName(i), searchPattern, topDirectoryOnly)); } } } break; case "exefs" when parts.Length == 1: case "exefs-partition-0" when parts.Length == 1: foreach (var file in GetPartitionOrDefault(0)?.ExeFs?.Headers ?.Where(h => searchPatternRegex.IsMatch(h.Filename) && !string.IsNullOrWhiteSpace(h.Filename)) ?.Select(h => h.Filename)) { output.Add("/ExeFS/" + file); } break; case "romfs": case "romfs-partition-0": addRomFsFiles(0); break; case "manual": case "romfs-partition-1": addRomFsFiles(1); break; case "downloadplay": case "romfs-partition-2": addRomFsFiles(2); break; case "n3dsupdate": case "romfs-partition-6": addRomFsFiles(6); break; case "o3dsupdate": case "romfs-partition-7": addRomFsFiles(7); break; default: if (dirName.StartsWith("romfs-partition-")) { var partitionNumRaw = dirName.Split("-".ToCharArray(), 3)[2]; if (int.TryParse(partitionNumRaw, out var partitionNum)) { addRomFsFiles(partitionNum); } } else if (dirName.StartsWith("exefs-partition-")) { var partitionNumRaw = dirName.Split("-".ToCharArray(), 3)[2]; if (int.TryParse(partitionNumRaw, out var partitionNum)) { foreach (var file in GetPartitionOrDefault(partitionNum)?.ExeFs?.Headers ?.Where(h => searchPatternRegex.IsMatch(h.Filename) && !string.IsNullOrWhiteSpace(h.Filename)) ?.Select(h => h.Filename)) { output.Add("/ExeFS/" + file); } } } break; } // Apply shadowed files var virtualPath = GetVirtualPath(path); if (CurrentFileSystem != null && CurrentFileSystem.DirectoryExists(virtualPath)) { foreach (var item in CurrentFileSystem.GetFiles(virtualPath, searchPattern, topDirectoryOnly)) { var overlayPath = "/" + SkyEditor.Core.Utilities.FileSystem.MakeRelativePath(item, VirtualPath); if (!BlacklistedPaths.Contains(overlayPath) && !output.Contains(overlayPath, StringComparer.OrdinalIgnoreCase)) { output.Add(overlayPath); } } } return(output.ToArray()); }