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-06-06 12:51:27 -07:00
|
|
|
|
using System;
|
2016-02-10 20:13:56 -08:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Extensions.EnvironmentAbstractions
|
|
|
|
|
{
|
|
|
|
|
internal class FileWrapper: IFile
|
|
|
|
|
{
|
|
|
|
|
public bool Exists(string path)
|
|
|
|
|
{
|
|
|
|
|
return File.Exists(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string ReadAllText(string path)
|
|
|
|
|
{
|
|
|
|
|
return File.ReadAllText(path);
|
|
|
|
|
}
|
2016-03-10 10:12:43 -08:00
|
|
|
|
|
|
|
|
|
public Stream OpenRead(string path)
|
|
|
|
|
{
|
|
|
|
|
return File.OpenRead(path);
|
|
|
|
|
}
|
2016-06-06 12:51:27 -07:00
|
|
|
|
|
2016-06-10 15:06:48 -07:00
|
|
|
|
public Stream OpenFile(
|
|
|
|
|
string path,
|
|
|
|
|
FileMode fileMode,
|
|
|
|
|
FileAccess fileAccess,
|
|
|
|
|
FileShare fileShare,
|
|
|
|
|
int bufferSize,
|
|
|
|
|
FileOptions fileOptions)
|
|
|
|
|
{
|
|
|
|
|
return new FileStream(path, fileMode, fileAccess, fileShare, bufferSize, fileOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-06 12:51:27 -07:00
|
|
|
|
public void CreateEmptyFile(string path)
|
|
|
|
|
{
|
2017-01-12 15:42:36 -08:00
|
|
|
|
using (File.Create(path))
|
2016-06-10 15:06:48 -07:00
|
|
|
|
{
|
|
|
|
|
}
|
2016-06-06 12:51:27 -07:00
|
|
|
|
}
|
2017-05-19 21:35:45 -07:00
|
|
|
|
|
|
|
|
|
public void WriteAllText(string path, string content)
|
|
|
|
|
{
|
|
|
|
|
File.WriteAllText(path, content);
|
|
|
|
|
}
|
2016-02-10 20:13:56 -08:00
|
|
|
|
}
|
2017-03-02 20:35:20 -08:00
|
|
|
|
}
|