mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-23 03:39:35 -10:00
Commit migrated from https://github.com/dotnet/corefx/commit/73ab96765fa59e5a1d224ecf804a29379da30c0b
43 lines
925 B
C#
43 lines
925 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
using System;
|
|
using System.IO;
|
|
|
|
public class TemporaryTestDirectory : IDisposable
|
|
{
|
|
public TemporaryTestDirectory(string path)
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
this.Path = path;
|
|
}
|
|
|
|
public string Path { get; private set; }
|
|
|
|
public void Move(string targetPath)
|
|
{
|
|
Directory.Move(this.Path, targetPath);
|
|
this.Path = targetPath;
|
|
}
|
|
|
|
// Use a finalizer to ensure we always clean up
|
|
~TemporaryTestDirectory()
|
|
{
|
|
Dispose(false);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected void Dispose(bool disposing)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.Path))
|
|
{
|
|
Utility.EnsureDelete(this.Path);
|
|
}
|
|
}
|
|
}
|