/// <summary> /// Recursively deletes a directory, making multiple attempts /// and suppressing any IO-related errors. /// </summary> /// <param name="path">The full path of the directory to delete.</param> /// <returns>True if the directory was successfully deleted.</returns> public static bool DeleteDirectoryWithRetries(this IFileSystem fs, string path, int maxRetries = 2) { for (var retries = maxRetries; retries > 0; --retries) { try { fs.DeleteDirectory(path, true); return(true); } catch (UnauthorizedAccessException) { } catch (IOException) { } } // Regular delete failed, so let's start removing the contents ourselves var directories = fs.GetDirectories(path).OrderByDescending(p => p.Length).ToArray(); foreach (var dir in directories) { foreach (var f in fs.GetFiles(dir, "*.*", SearchOption.TopDirectoryOnly)) { fs.DeleteFile(f); } try { fs.DeleteDirectory(dir, true); } catch (UnauthorizedAccessException) { } catch (IOException) { } } // If we get to this point and the directory still exists, there's // likely nothing we can do. return(!fs.DirectoryExists(path)); }
public async Task CancelJob(string id) { var job = GetJob(id); if (job == null) { throw new ArgumentException("Job not found."); } await _repo.DeleteJob(id).ConfigureAwait(false); var path = GetSyncJobProcessor().GetTemporaryPath(id); try { _fileSystem.DeleteDirectory(path, true); } catch (DirectoryNotFoundException) { } catch (Exception ex) { _logger.ErrorException("Error deleting directory {0}", ex, path); } if (SyncJobCancelled != null) { EventHelper.FireEventIfNotNull(SyncJobCancelled, this, new GenericEventArgs <SyncJob> { Argument = job }, _logger); } }
public override void TearDown() { if (fs.DirectoryExists("/upload/")) { fs.DeleteDirectory("/upload/"); } base.TearDown(); }
public void Delete(string deleteDirectory) { var directory = GetDirectory(deleteDirectory); if (_fs.DirectoryExists(directory)) { _fs.DeleteDirectory(directory); } }
public void Can_Overwrite_File() { _fileSystem.AddFile("test/test.txt", CreateStream()); _fileSystem.AddFile("test/test.txt", CreateStream()); var files = _fileSystem.GetFiles("test"); Assert.AreEqual(1, files.Count()); _fileSystem.DeleteDirectory("test", true); }
public SolutionGraphScenarioDefinition() { _directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString()); _fileSystem.CleanDirectory(_directory); _fileSystem.DeleteDirectory(_directory); _fileSystem.DeleteDirectory(_directory); _fileSystem.CreateDirectory(_directory); _fileSystem.CreateDirectory(cacheDirectory); }
public SolutionGraphScenarioDefinition() { _directory = Path.GetTempPath().AppendRandomPath(); _fileSystem.CleanDirectory(_directory); _fileSystem.DeleteDirectory(_directory); _fileSystem.DeleteDirectory(_directory); _fileSystem.CreateDirectory(_directory); _fileSystem.CreateDirectory(cacheDirectory); }
/// <summary> /// Performs all the tasks necessary before starting the export process. /// </summary> protected void PrepareForExport() { // create the working directory string tempFileName = Path.GetTempFileName(); _baseTempDirectory = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(tempFileName)); _fileSystem.DeleteFile(tempFileName); TempDirectory = Path.Combine(_baseTempDirectory, "XML\\"); _fileSystem.CreateDirectory(TempDirectory); OutputDirectory = Path.Combine(_baseTempDirectory, "Output\\"); _fileSystem.CreateDirectory(OutputDirectory); // get the publish path and clean/create the directory if (string.IsNullOrEmpty(this.Settings.PublishDirectory)) { // no output directory set, default to my documents live document folder string publishPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Live Documenter\\Published\\"); this.PublishDirectory = publishPath; } else { this.PublishDirectory = Settings.PublishDirectory; } // #38 always add a new export directory to the publish location, this is to stop people deleting their // files and folders. DateTime now = DateTime.Now; this.PublishDirectory = Path.Combine(PublishDirectory, string.Format("LD Export - {4:0000}{3:00}{2:00} {1:00}{0:00}\\", now.Minute, now.Hour, now.Day, now.Month, now.Year)); if (_fileSystem.DirectoryExists(PublishDirectory)) { _fileSystem.DeleteDirectory(PublishDirectory, true); System.Threading.Thread.Sleep(0); } // #183 fixes issue as directory is not recreated when user has folder open in explorer int counter = 0; while (counter < 10 && _fileSystem.DirectoryExists(PublishDirectory)) { counter++; System.Threading.Thread.Sleep(60); } _fileSystem.CreateDirectory(PublishDirectory); // read the current application directory this.ApplicationDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); }
public CommandResult Execute() { _logger.Info("Cleaning initiated..."); var workingDirectory = _fileSystem.GetWorkingDirectory(_scriptName); _logger.TraceFormat("Working directory: {0}", workingDirectory); var binFolder = Path.Combine(workingDirectory, Constants.BinFolder); _logger.TraceFormat("Bin folder: {0}", binFolder); var packageFolder = Path.Combine(workingDirectory, Constants.PackagesFolder); _logger.TraceFormat("Packages folder: {0}", packageFolder); try { if (_fileSystem.DirectoryExists(binFolder)) { var packages = _packageAssemblyResolver.GetAssemblyNames(workingDirectory); foreach (var package in packages) { _logger.DebugFormat("Deleting file: {0}", package); DeleteFile(package, binFolder); } var remaining = _fileSystem.EnumerateFiles(binFolder, "*.*").Any(); if (!remaining) { _logger.DebugFormat("Deleting bin directory: {0}", binFolder); _fileSystem.DeleteDirectory(binFolder); } } if (_fileSystem.DirectoryExists(packageFolder)) { _logger.DebugFormat("Deleting package directory: {0}", packageFolder); _fileSystem.DeleteDirectory(packageFolder); } _logger.Info("Clean completed successfully."); return(CommandResult.Success); } catch (Exception e) { _logger.ErrorFormat("Clean failed: {0}.", e.Message); return(CommandResult.Error); } }
public static TemplateLibrary BuildClean(string root) { FileSystem.DeleteDirectory(root); FileSystem.CreateDirectory(root); return(new TemplateLibrary(root)); }
public CommandResult Execute() { _logger.Info("Cleaning initiated..."); var workingDirectory = _fileSystem.GetWorkingDirectory(_scriptName); _logger.TraceFormat("Working directory: {0}", workingDirectory); var packageFolder = Path.Combine(workingDirectory, Constants.PackagesFolder); _logger.TraceFormat("Packages folder: {0}", packageFolder); try { if (_fileSystem.DirectoryExists(packageFolder)) { _logger.DebugFormat("Deleting package directory: {0}", packageFolder); _fileSystem.DeleteDirectory(packageFolder); } _logger.Info("Clean completed successfully."); return(CommandResult.Success); } catch (Exception e) { _logger.ErrorFormat("Clean failed: {0}.", e.Message); return(CommandResult.Error); } }
private static bool IsWritable(IFileSystem save) { // ok so F**K nintendo // their filesystem interface doesn't define RW privileges // so I have to guess lol try { save.CreateDirectory("/tmp"); save.RenameDirectory("/tmp", "/temp"); save.DeleteDirectory("/temp"); save.CreateFile("/tmp.bin", 0, CreateFileOptions.None); IFile temp = save.OpenFile("/tmp.bin", OpenMode.ReadWrite); temp.SetSize(0x4); byte[] testBytes = new byte[] { 0xBA, 0xDF, 0x00, 0xD }; temp.Write(testBytes, 0); byte[] buff = new byte[4]; temp.Read(buff, 0); save.RenameFile("/tmp.bin", "/temp.bin"); save.DeleteFile("/temp.bin"); if (!buff.SequenceEqual(testBytes)) { return(false); } return(true); } catch (NotImplementedException) { return(false); } catch (NotSupportedException) { return(false); } }
public ActionResult Execute(string id) { var deployment = deploymentRepository.GetAll().Where(a => a.Id == id).FirstOrDefault(); var batch = textTemplateBatchContext.GetAll().Where(a => a.Id == deployment.TextTemplateBatchId).FirstOrDefault(); t4StateContext.SetState(deployment.StateXml); var zipFilePath = getWorkingFolderPath.GetPathToWorkingFolder() + "TextTemplateBatchFileUploads" + Path.DirectorySeparatorChar + batch.Id + Path.DirectorySeparatorChar + batch.ZipFilename; var outputPath = getWorkingFolderPath.GetPathToWorkingFolder() + "T4Output" + Path.DirectorySeparatorChar + deployment.Id + Path.DirectorySeparatorChar; if (fileSystem.DirectoryExists(outputPath)) { fileSystem.DeleteDirectory(outputPath); } var errors = textTemplateZipProcessor.ProcessZip(zipFilePath, outputPath); if (deployment.DeployToGitRepository) { deployToBranchService.Deploy(new GitDeploymentTarget() { BranchName = deployment.BranchName, RepositoryUrl = deployment.RepositoryUrl }, outputPath); } return(View("Execute", new ExecuteViewModel() { OutputPath = outputPath, Errors = errors, })); }
public async Task OpenFile(BinaryFile file) { // Clear virtual path if it exists if (!string.IsNullOrEmpty(VirtualPath) && CurrentFileSystem.DirectoryExists(VirtualPath)) { CurrentFileSystem.DeleteDirectory(VirtualPath); } VirtualPath = CurrentFileSystem.GetTempDirectory(); if (await NcsdFile.IsNcsd(file)) { Container = await NcsdFile.Load(file); } else if (await CiaFile.IsCia(file)) { Container = await CiaFile.Load(file); } else if (await NcchPartition.IsNcch(file)) { Container = new SingleNcchPartitionContainer(await NcchPartition.Load(file)); } else if (await RomFs.IsRomFs(file)) { Container = new SingleNcchPartitionContainer(new NcchPartition(romfs: await RomFs.Load(file))); } else if (await ExeFs.IsExeFs(file)) { Container = new SingleNcchPartitionContainer(new NcchPartition(exefs: await ExeFs.Load(file))); } else { throw new BadImageFormatException(Properties.Resources.ThreeDsRom_UnsupportedFileFormat); } }
/// <summary> /// Cleans temp folder specific for the application. /// </summary> /// <param name="fileSystem">File system instance.</param> /// <param name="applicationKey">Application key (actually it's sub-folder of temp directory).</param> public static void CleanFolder(IFileSystem fileSystem, string applicationKey) { Argument.IsNotNull(fileSystem, nameof(fileSystem)); Argument.IsNotEmpty(applicationKey, nameof(applicationKey)); var rootApplicationFolder = Path.Combine(fileSystem.GetTempPath(), applicationKey); if (!fileSystem.DirectoryExists(rootApplicationFolder)) { return; } var fileSystemEntries = fileSystem .EnumerateFileSystemEntries(rootApplicationFolder, @"*.*", SearchOption.AllDirectories) .OrderByDescending(f => f.Length); foreach (var fileSystemEntry in fileSystemEntries) { try { if (fileSystem.FileExists(fileSystemEntry)) { fileSystem.DeleteFile(fileSystemEntry); } else if (fileSystem.DirectoryExists(fileSystemEntry)) { fileSystem.DeleteDirectory(fileSystemEntry); } } catch (IOException t) { Trace.WriteLine(Invariant($"{t.Message}\r\n{t.StackTrace}")); } } }
/// <summary> /// Performs a directory deletion. /// </summary> /// <param name="fileSystem">The file system.</param> /// <param name="directory">The directory to delete.</param> /// <param name="execute">if set to true, the operation gets executed.</param> private void PerformDirectoryDeletionOperation(IFileSystem fileSystem, IDirectoryInfo directory, bool execute) { var eventArgs = new DirectoryDeletionEventArgs(directory.FullName); this.OnDeletingDirectory(eventArgs); var directoryScanner = new FileSystemScanner(directory); directoryScanner.FileFound += (sender, e) => this.OnProceededFile(new FileProceededEventArgs(e.File.FullName, e.File.Length)); directoryScanner.Start(); if (execute) { try { fileSystem.DeleteDirectory(directory); this.OnDeletedDirectory(eventArgs); } catch (AccessException) { this.OnDirectoryDeletionError(new DirectoryDeletionEventArgs(directory.FullName)); } } }
private List <CodegenJob> PrepareOutputFolders(CodegenJob[] jobs) { var outputDirectories = jobs.Select(job => job.OutputDirectory).Distinct(); foreach (var outputDirectory in outputDirectories) { var relatedJobs = jobs.Where(job => job.OutputDirectory == outputDirectory); if (!IsOutputDirectoryDirty(relatedJobs, outputDirectory)) { continue; } logger.Trace($"Deleting dirty directory {outputDirectory}."); fileSystem.DeleteDirectory(outputDirectory); foreach (var job in relatedJobs) { logger.Trace($"Marking {job.GetType()} as dirty."); job.MarkAsDirty(); } } return(jobs.Where(job => job.IsDirty()).ToList()); }
public bool Initialize(InitializeInput input, IFileSystem fileSystem, ISimpleLogger logger) { var deploymentDirectory = input.Settings.DeploymentDirectory; logger.Log("Trying to initialize Bottles deployment folders at {0}", deploymentDirectory); if (fileSystem.DirectoryExists(deploymentDirectory)) { if (input.ForceFlag) { logger.Log(DELETING_EXISTING_DIRECTORY, deploymentDirectory); fileSystem.CleanDirectory(deploymentDirectory); fileSystem.DeleteDirectory(deploymentDirectory); Thread.Sleep(10); //file system is async } else { logger.Log(DIRECTORY_ALREADY_EXISTS, deploymentDirectory); return(false); } } createDirectory(fileSystem, logger, deploymentDirectory); Console.WriteLine("Writing blank file to " + input.Settings.BottleManifestFile); fileSystem.WriteStringToFile(input.Settings.BottleManifestFile, ""); createDirectory(fileSystem, logger, input.Settings.BottlesDirectory); createDirectory(fileSystem, logger, input.Settings.RecipesDirectory); createDirectory(fileSystem, logger, input.Settings.EnvironmentsDirectory); createDirectory(fileSystem, logger, input.Settings.ProfilesDirectory); return(true); }
public async Task <object> Get(GetDashboardPackage request) { var path = Path.Combine(_serverConfigurationManager.ApplicationPaths.ProgramDataPath, "webclient-dump"); try { _fileSystem.DeleteDirectory(path, true); } catch (IOException) { } var creator = GetPackageCreator(); CopyDirectory(creator.DashboardUIPath, path); var culture = "en-US"; var appVersion = DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture); await DumpHtml(creator.DashboardUIPath, path, culture, appVersion); await DumpJs(creator.DashboardUIPath, path, culture, appVersion); await DumpFile("scripts/all.js", Path.Combine(path, "scripts", "all.js"), culture, appVersion).ConfigureAwait(false); await DumpFile("css/all.css", Path.Combine(path, "css", "all.css"), culture, appVersion).ConfigureAwait(false); return(""); }
private void View_DeleteDirectory(object sender, DirectoryEventArgs e) { if (!_dialogView.ConfirmDelete(e.FullPath)) { return; } try { _fileSystem.DeleteDirectory(e.FullPath, true); View.RemoveDirectory(PathUtils.Split(e.FullPath)); } catch (DirectoryNotFoundException) { _dialogView.DirectoryNotFound(e.FullPath); // we stil want to remove the directory from the view View.RemoveDirectory(PathUtils.Split(e.FullPath)); } catch (UnauthorizedAccessException) { _dialogView.UnauthorizedAccess(e.FullPath); } catch (IOException) { _dialogView.FileInUse(e.FullPath); } }
public async Task <object> Get(GetDashboardPackage request) { var mode = request.Mode; var inputPath = string.IsNullOrWhiteSpace(mode) ? DashboardUIPath : "C:\\dev\\emby-web-mobile-master\\dist"; var targetPath = !string.IsNullOrWhiteSpace(mode) ? inputPath : "C:\\dev\\emby-web-mobile\\src"; var packageCreator = GetPackageCreator(inputPath); if (!string.Equals(inputPath, targetPath, StringComparison.OrdinalIgnoreCase)) { try { _fileSystem.DeleteDirectory(targetPath, true); } catch (IOException) { } CopyDirectory(inputPath, targetPath); } string culture = null; var appVersion = _appHost.ApplicationVersion.ToString(); await DumpHtml(packageCreator, inputPath, targetPath, mode, culture, appVersion); return(""); }
internal static string SaveFilesToTemp(this IFileSystem fileSystem, string folderName = null) { folderName = string.IsNullOrWhiteSpace(folderName) ? Guid.NewGuid().ToString() : folderName; var outputFolder = Path.Combine(Path.GetTempPath(), folderName); if (Directory.Exists(outputFolder)) { try { fileSystem.EmptyDirectory(outputFolder); fileSystem.DeleteDirectory(outputFolder); } catch { // who cares... } } Directory.CreateDirectory(outputFolder); foreach (var file in fileSystem.GetFiles("", "*", SearchOption.AllDirectories)) { var target = Path.Combine(outputFolder, file.Substring(file.IndexOf(":", StringComparison.Ordinal) + 1)); Directory.CreateDirectory(Path.GetDirectoryName(target)); File.WriteAllText(target, fileSystem.ReadFileAsText(file)); } return(outputFolder); }
internal static void Copy(this IFileSystem fileSystem, string source, string destination) { // if copying a file if (File.Exists(source)) { fileSystem.WriteFile(destination, File.ReadAllText(source)); return; } // if copying a directory if (fileSystem.DirectoryExists(destination)) { fileSystem.DeleteDirectory(destination); } fileSystem.CreateDirectory(destination); // Copy dirs recursively foreach (var child in Directory.GetDirectories(Path.GetFullPath(source), "*", SearchOption.TopDirectoryOnly).Select(p => Path.GetDirectoryName(p))) { fileSystem.Copy(Path.Combine(source, child), Path.Combine(destination, child)); } // Copy files foreach (var childFile in Directory.GetFiles(Path.GetFullPath(source), "*", SearchOption.TopDirectoryOnly).Select(p => Path.GetFileName(p))) { fileSystem.Copy(Path.Combine(source, childFile), Path.Combine(destination, childFile)); } }
public RemoveResult Execute(RemoveState state) { try { var targets = state.Target.Raw.Split(","); foreach (var target in targets) { // TODO: implicit/explicit conversion operators to/from string for NPath if (_fileSystem.DirectoryExists(new NPath(target))) { _fileSystem.DeleteDirectory(new NPath(target), true); } else if (_fileSystem.FileExists(new NPath(target))) { _fileSystem.DeleteFile(new NPath(target)); } } Result = new RemoveResult(true, new[] { "ok" }); } catch (Exception e) { Console.WriteLine(e); Result = new RemoveResult(false, null); } return(Result); }
public void DeleteMarkedPackageDirectories() { IFileSystem repositoryFileSystem = _repositoryFileSystemFactory(); try { foreach (string deletemePath in repositoryFileSystem.GetFiles(path: "", filter: DeletionMarkerFilter, recursive: false)) { string deletedPackageDirectoryPath = Path.GetFileNameWithoutExtension(deletemePath); try { // DeleteDirectory should not throw a DirectoryNotFoundException. It might throw an IOException, UnauthorizedAccessException, etc... repositoryFileSystem.DeleteDirectory(deletedPackageDirectoryPath, recursive: true); } finally { if (!repositoryFileSystem.DirectoryExists(deletedPackageDirectoryPath)) { repositoryFileSystem.DeleteFile(deletemePath); } else { repositoryFileSystem.Logger.Log(MessageLevel.Warning, String.Format(Resources.VsResources.Warning_FailedToDeleteMarkedPackageDirectory, deletedPackageDirectoryPath)); } } } } catch (Exception e) { repositoryFileSystem.Logger.Log(MessageLevel.Warning, String.Format(Resources.VsResources.Warning_FailedToDeleteMarkedPackageDirectories, e.Message)); } }
private bool RecursivelyRemoveEmptyDirectories(string path) { var oks = _fs.GetDirectories(path).Select(RecursivelyRemoveEmptyDirectories).ToList(); if (!oks.All(ok => ok)) { return(false); } if (_fs.GetFiles(path).Any()) { return(false); } try { _fs.DeleteDirectory(path); return(true); } catch (Exception e) { LogLog.Error(typeof(FileSystemOperations), $"Could not delete directory '{path}", e); return(false); } }
public async Task <int> CalculateEpisodeCount(string seriesId, string preferredMetadataLanguage, CancellationToken cancellationToken) { var fullPath = _serverApplicationPaths.PluginsPath + "\\\\Statistics"; _fileSystem.CreateDirectory(fullPath); var url = string.Format(SeriesGetZip, ApiKey, seriesId, NormalizeLanguage(preferredMetadataLanguage)); using (var zipStream = await _httpClient.Get(new HttpRequestOptions { Url = url, ResourcePool = TvDbResourcePool, CancellationToken = cancellationToken }).ConfigureAwait(false)) { DeleteXmlFiles(fullPath); using (var ms = new MemoryStream()) { await zipStream.CopyToAsync(ms).ConfigureAwait(false); ms.Position = 0; _zipClient.ExtractAllFromZip(ms, fullPath, true); } } var downloadLangaugeXmlFile = Path.Combine(fullPath, NormalizeLanguage(preferredMetadataLanguage) + ".xml"); var result = ExtractEpisodes(downloadLangaugeXmlFile); _fileSystem.DeleteDirectory(fullPath, true); return(result); }
private string DoConfigure(string packagePath, Environment env, string outputPath) { _logger.InfoFormat("Configuring package {0} for {1}", new FileInfo(packagePath).Name, env.Name.ToUpper()); var workingDir = _fileSystem.CreateTempWorkingDir(); _logger.DebugFormat("Create temp work dir {0}", workingDir); // read nupkg metadata var nupkg = new ZipPackage(packagePath); _logger.DebugFormat("Unzipping {0} to {1}", nupkg.GetFullName(), workingDir); using (var zip = new ZipFile(packagePath)) { zip.ExtractAll(workingDir); } _templateEngine.TransformDirectory(workingDir, env); var packageName = nupkg.Id + "_v" + nupkg.Version + "_" + env.Name.ToUpper(CultureInfo.InvariantCulture) + ".nupkg"; var packageOutputPath = Path.Combine(outputPath, packageName); _fileSystem.DeleteFile(packageOutputPath); using (var zip = new ZipFile(packageOutputPath)) { zip.AddDirectory(workingDir); zip.Save(); } _fileSystem.DeleteDirectory(workingDir); return(packageOutputPath); }
public int Run(ResultMatchSetOptions options) { options.OutputFolderPath = options.OutputFolderPath ?? Path.Combine(options.FolderPath, "Out"); ISarifLogMatcher matcher = ResultMatchingBaselinerFactory.GetDefaultResultMatchingBaseliner(); Formatting formatting = options.PrettyPrint ? Formatting.Indented : Formatting.None; // Remove previous results. if (_fileSystem.DirectoryExists(options.OutputFolderPath)) { _fileSystem.DeleteDirectory(options.OutputFolderPath, true); } // Create output folder. _fileSystem.CreateDirectory(options.OutputFolderPath); string previousFileName = ""; string previousGroup = ""; SarifLog previousLog = null, currentLog = null; foreach (string filePath in Directory.GetFiles(options.FolderPath, "*.sarif")) { string fileName = Path.GetFileName(filePath); string currentGroup = GetGroupName(fileName); try { currentLog = ReadSarifFile <SarifLog>(_fileSystem, filePath); // Compare each log with the previous one in the same group. if (currentGroup.Equals(previousGroup) && currentLog?.Runs?[0]?.Results.Count != 0 && previousLog?.Runs?[0]?.Results.Count != 0) { Console.WriteLine(); Console.WriteLine($"{previousFileName} -> {fileName}:"); SarifLog mergedLog = matcher.Match(new[] { previousLog }, new[] { currentLog }).First(); // Write the same and different count and different IDs. WriteDifferences(mergedLog); // Write the log, if there were any changed results if (mergedLog.Runs[0].Results.Any(r => r.BaselineState != BaselineState.Unchanged)) { string outputFilePath = Path.Combine(options.OutputFolderPath, fileName); WriteSarifFile(_fileSystem, mergedLog, outputFilePath, formatting); } } } catch (Exception ex) when(!Debugger.IsAttached) { Console.WriteLine(ex.ToString()); } previousFileName = fileName; previousGroup = currentGroup; previousLog = currentLog; } return(0); }
public void DeleteDirectory_DoesNotExist_ReturnsPathNotFound() { IFileSystem fs = CreateFileSystem(); Result rc = fs.DeleteDirectory("/dir".ToU8Span()); Assert.Result(ResultFs.PathNotFound, rc); }
private static string DeleteTempTestDir(IFileSystem fileSystem) { if (fileSystem.DirectoryExists(TestConstants.TempDirectory)) { fileSystem.DeleteDirectory(TestConstants.TempDirectory); } return TestConstants.TempDirectory; }
public static void Close(IFileSystem fileSystem) { var folder = GetTempCsvFilesFolder(); if (fileSystem.DirectoryExists(folder)) { // Note: some files may still be locked if they are opened in Excel try { fileSystem.DeleteDirectory(folder, recursive: true); } catch (IOException) { } catch (UnauthorizedAccessException) { } } }
public void Clean(IFileSystem fileSystem, CleanMode mode) { if (mode == CleanMode.all || mode == CleanMode.packages) { var packagesFolder = PackagesFolder(); Console.WriteLine("Deleting " + packagesFolder); fileSystem.DeleteDirectory(packagesFolder); } if (mode == CleanMode.all || mode == CleanMode.projects) { _projects.Each(p => p.Clean(fileSystem)); } }