2016-02-10 20:13:56 -08: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.
|
|
|
|
|
|
2016-08-22 13:20:17 -07:00
|
|
|
|
using System.Collections.Generic;
|
2016-02-10 20:13:56 -08:00
|
|
|
|
using System.IO;
|
2016-06-03 17:36:40 -07:00
|
|
|
|
using Microsoft.DotNet.InternalAbstractions;
|
2016-02-10 20:13:56 -08:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.Extensions.EnvironmentAbstractions
|
|
|
|
|
{
|
|
|
|
|
internal class DirectoryWrapper: IDirectory
|
|
|
|
|
{
|
|
|
|
|
public bool Exists(string path)
|
|
|
|
|
{
|
|
|
|
|
return Directory.Exists(path);
|
|
|
|
|
}
|
2016-06-03 17:36:40 -07:00
|
|
|
|
|
|
|
|
|
public ITemporaryDirectory CreateTemporaryDirectory()
|
|
|
|
|
{
|
|
|
|
|
return new TemporaryDirectory();
|
|
|
|
|
}
|
2016-08-22 13:20:17 -07:00
|
|
|
|
|
|
|
|
|
public IEnumerable<string> GetFiles(string path, string searchPattern)
|
|
|
|
|
{
|
|
|
|
|
return Directory.GetFiles(path, searchPattern);
|
|
|
|
|
}
|
2016-08-25 22:53:04 -07:00
|
|
|
|
|
|
|
|
|
public string GetDirectoryFullName(string path)
|
|
|
|
|
{
|
|
|
|
|
var directoryFullName = string.Empty;
|
|
|
|
|
if (Exists(path))
|
|
|
|
|
{
|
|
|
|
|
directoryFullName = new DirectoryInfo(path).FullName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var fileInfo = new FileInfo(path);
|
|
|
|
|
if (fileInfo.Directory != null)
|
|
|
|
|
{
|
|
|
|
|
directoryFullName = fileInfo.Directory.FullName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return directoryFullName;
|
|
|
|
|
}
|
2017-05-31 13:44:03 -07:00
|
|
|
|
|
|
|
|
|
public void CreateDirectory(string path)
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
2016-02-10 20:13:56 -08:00
|
|
|
|
}
|
2017-03-02 20:35:20 -08:00
|
|
|
|
}
|