-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
namespace Watchtower.Core; | ||
using FsPath = Path; | ||
|
||
public class ProjectFile | ||
{ | ||
public required string Path { get; init; } | ||
|
||
public string FileName => FsPath.GetFileName(Path); | ||
|
||
public string? DirPath => FsPath.GetDirectoryName(Path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Watchtower.Core; | ||
|
||
namespace Watchtower.Playground; | ||
|
||
public class Storage | ||
{ | ||
private string Root { get; } | ||
|
||
public Storage(string root) | ||
{ | ||
Root = root; | ||
Directory.CreateDirectory(root); | ||
} | ||
|
||
public async Task PutFileAsync(Project project, ProjectFile file, Task<string> contents) | ||
{ | ||
var dir = $"{GetProjectPath(project)}/{file.DirPath}"; | ||
Directory.CreateDirectory(dir); | ||
await File.WriteAllTextAsync($"{dir}/{file.FileName}", await contents); | ||
} | ||
|
||
public bool IsProjectStoredAsync(Project project) => Directory.Exists(GetProjectPath(project)); | ||
|
||
private string GetProjectPath(Project project) => | ||
$"{Root}/@{project.Namespace}@/@@{project.Name}@@/__{project.DefaultBranch}__"; | ||
} |