summary refs log tree commit diff
path: root/LibGitTest/FileRepoSource.cs
blob: 94d767f17ae76a84e0088f985eb8f5574fd5f002 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using LibGit.Interfaces;

namespace LibGitTest;

public class FileRepoSource : IRepoSource
{
    public FileRepoSource(string basePath)
    {
        BasePath = basePath;
        if (!Directory.Exists(BasePath)) Console.WriteLine("Warning: Base path does not exist: " + BasePath);
    }

    public string BasePath { get; set; }

    public async Task<bool> FileExists(string path)
    {
        return File.Exists(Path.Join(BasePath, path));
    }

    public async Task<Stream> GetFileStream(string path)
    {
        return File.OpenRead(Path.Join(BasePath, path));
    }
}