-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSourceWriter.cs
33 lines (27 loc) · 889 Bytes
/
SourceWriter.cs
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
using System;
using System.IO;
namespace DotGLFW.Generator;
public class SourceWriter : ISourceWriter
{
private readonly string _outputDirectory;
public SourceWriter(string outputDirectory)
{
_outputDirectory = outputDirectory;
}
public void WriteToFile(string filePath, string content)
{
if (!Directory.Exists(_outputDirectory))
{
Directory.CreateDirectory(_outputDirectory);
Console.WriteLine($"Created directory: {_outputDirectory}");
}
if (File.Exists(Path.Combine(_outputDirectory, filePath)))
{
File.Delete(Path.Combine(_outputDirectory, filePath));
Console.WriteLine($"Deleted existing file: {filePath}");
}
using var writer = new StreamWriter(Path.Combine(_outputDirectory, filePath), false);
writer.Write(content);
Console.WriteLine($"Wrote file: {filePath}");
}
}