33 lines
933 B
C#
33 lines
933 B
C#
|
|
using System;
|
||
|
|
using System.IO;
|
||
|
|
|
||
|
|
namespace MaddoShared.ImageSharpTests.Helpers
|
||
|
|
{
|
||
|
|
public sealed class TempWorkspace : IDisposable
|
||
|
|
{
|
||
|
|
public DirectoryInfo Root { get; }
|
||
|
|
public DirectoryInfo SourceDir { get; }
|
||
|
|
public DirectoryInfo DestDir { get; }
|
||
|
|
|
||
|
|
public TempWorkspace()
|
||
|
|
{
|
||
|
|
var root = Path.Combine(Path.GetTempPath(), "MaddoShared.ImageSharpTests", Guid.NewGuid().ToString("N"));
|
||
|
|
Root = Directory.CreateDirectory(root);
|
||
|
|
SourceDir = Directory.CreateDirectory(Path.Combine(Root.FullName, "Source"));
|
||
|
|
DestDir = Directory.CreateDirectory(Path.Combine(Root.FullName, "Dest"));
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Dispose()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
if (Root.Exists)
|
||
|
|
Root.Delete(true);
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
// best-effort cleanup
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|