/// <summary> /// Deletes files and directories scheduled for deletion by the settings provider. /// </summary> /// <param name="settings"><see cref="ISettingsProvider"/> managing the files and directories scheduled for deletion.</param> /// <param name="provider"><see cref="IFileSystem"/> managing where the files and directories are located.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="settings"/> or <paramref name="provider"/> is null.</exception> protected async Task DeleteScheduledFiles(ISettingsProvider settings, IFileSystem provider) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (provider == null) { throw new ArgumentNullException(nameof(settings)); } // Files foreach (var item in settings.GetFilesScheduledForDeletion().ToList()) // Create a new list because the original will be continuously modified { if (CurrentFileSystem.FileExists(item)) { CurrentFileSystem.DeleteFile(item); } CurrentSettingsProvider.UnscheduleFileForDeletion(item); await CurrentSettingsProvider.Save(provider); } // Directories foreach (var item in settings.GetDirectoriesScheduledForDeletion().ToList()) { if (CurrentFileSystem.DirectoryExists(item)) { CurrentFileSystem.DeleteDirectory(item); } CurrentSettingsProvider.UnscheduleDirectoryForDeletion(item); await CurrentSettingsProvider.Save(provider); } }
void IFileSystem.DeleteDirectory(string path) { var fixedPath = FixPath(path); if (!BlacklistedPaths.Contains(fixedPath)) { BlacklistedPaths.Add(fixedPath); } var virtualPath = GetVirtualPath(path); if (CurrentFileSystem != null && CurrentFileSystem.FileExists(virtualPath)) { CurrentFileSystem.DeleteFile(virtualPath); } }
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]))); } } } }
byte[] IFileSystem.ReadAllBytes(string filename) { var fixedPath = FixPath(filename); if (BlacklistedPaths.Contains(fixedPath)) { throw new FileNotFoundException(string.Format(Properties.Resources.ThreeDsRom_ErrorRomFileNotFound, filename), filename); } else { var virtualPath = GetVirtualPath(fixedPath); if (CurrentFileSystem != null && CurrentFileSystem.FileExists(virtualPath)) { return(CurrentFileSystem.ReadAllBytes(virtualPath)); } else { var data = GetDataReference(GetPathParts(filename)); return(data.ReadArray()); } } }
public override async Task MainAsync(string[] arguments) { if (arguments.Length > 1) { if (CurrentFileSystem.FileExists(arguments[1])) { var result = await ExtensionHelper.InstallExtensionZip(arguments[1], CurrentPluginManager).ConfigureAwait(false); if (result == ExtensionInstallResult.Success) { Console.WriteLine("Extension install was successful."); } else if (result == ExtensionInstallResult.RestartRequired) { Console.WriteLine("Application must be restarted to complete installation."); } else if (result == ExtensionInstallResult.InvalidFormat) { Console.WriteLine("The provided zip file is not a Sky Editor extension."); } else if (result == ExtensionInstallResult.UnsupportedFormat) { Console.WriteLine("The provided extension is not supported. Is this an extension to an extension that's not currently installed?"); } else { Console.WriteLine("Unknown error."); } } else { Console.WriteLine("File doesn't exist."); } } else { Console.WriteLine("Usage: InstallExtension <Filename>"); } }
bool IFileSystem.FileExists(string filename) { return((CurrentFileSystem != null && CurrentFileSystem.FileExists(GetVirtualPath(filename))) || GetDataReference(GetPathParts(filename), false) != null); }