2016-04-22 12:17:36 -07:00
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.TestFramework
|
|
|
|
{
|
|
|
|
public class TestDirectory
|
|
|
|
{
|
|
|
|
internal TestDirectory(string path)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(path))
|
|
|
|
{
|
2016-04-25 11:22:32 -07:00
|
|
|
throw new ArgumentException(nameof(path));
|
2016-04-22 12:17:36 -07:00
|
|
|
}
|
|
|
|
|
2016-04-25 11:22:32 -07:00
|
|
|
Path = path;
|
2016-04-22 12:17:36 -07:00
|
|
|
|
2016-04-25 11:22:32 -07:00
|
|
|
EnsureExistsAndEmpty(Path);
|
2016-04-22 12:17:36 -07:00
|
|
|
}
|
|
|
|
|
2016-04-25 11:22:32 -07:00
|
|
|
public string Path { get; private set; }
|
2016-04-22 12:17:36 -07:00
|
|
|
|
2016-04-25 11:22:32 -07:00
|
|
|
private static void EnsureExistsAndEmpty(string path)
|
2016-04-22 12:17:36 -07:00
|
|
|
{
|
|
|
|
if (Directory.Exists(path))
|
|
|
|
{
|
|
|
|
Directory.Delete(path, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
}
|
|
|
|
}
|
2016-04-25 11:22:32 -07:00
|
|
|
}
|