-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDotNetFileSystemProvider.cs
More file actions
57 lines (52 loc) · 1.67 KB
/
DotNetFileSystemProvider.cs
File metadata and controls
57 lines (52 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections.Generic;
using System.IO;
namespace Skarp.Version.Cli.CsProj.FileSystem
{
public class DotNetFileSystemProvider : IFileSystemProvider
{
/// <summary>
/// List the files of the given path
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public IEnumerable<string> List(string path)
{
return Directory.EnumerateFiles(path);
}
/// <summary>
/// Determines whether the given path is actually a csproj or targets file
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public bool IsCsProjectFile(string path)
{
return File.Exists(path) && (path.EndsWith(".csproj") || path.EndsWith(".targets") || path.EndsWith(".props"));
}
/// <summary>
/// Gets the current working directory of the running application
/// </summary>
/// <returns></returns>
public string Cwd()
{
return Directory.GetCurrentDirectory();
}
/// <summary>
/// Load content from the given file
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public string LoadContent(string filePath)
{
return File.ReadAllText(filePath);
}
/// <summary>
/// Write all text content to the given filepath
/// </summary>
/// <param name="filePath"></param>
/// <param name="data"></param>
public void WriteAllContent(string filePath, string data)
{
File.WriteAllText(filePath, data);
}
}
}