Skip to content

Commit

Permalink
fix: write test file to base
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Apr 1, 2024
1 parent 2045516 commit 0810efd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/GZCTF/Utils/FilePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum DirType : byte

static class FilePath
{
const string Base = "files";
const string _base = "files";

internal static readonly string Logs = GetDir(DirType.Logs);
internal static readonly string Uploads = GetDir(DirType.Uploads);
Expand All @@ -29,24 +29,24 @@ internal static bool AllowBaseCreate(IHostEnvironment environment)

internal static async Task EnsureDirsAsync(IHostEnvironment environment)
{
if (!Directory.Exists(Base))
if (!Directory.Exists(_base))
{
if (AllowBaseCreate(environment))
Directory.CreateDirectory(Base);
Directory.CreateDirectory(_base);
else
Program.ExitWithFatalMessage(
Program.StaticLocalizer[nameof(Resources.Program.Init_NoFilesDir), Path.GetFullPath(Base)]);
Program.StaticLocalizer[nameof(Resources.Program.Init_NoFilesDir), Path.GetFullPath(_base)]);
}

await using (var versionFile = File.Open("version.txt", FileMode.Create))
await using (var versionFile = File.Open(Path.Combine(_base, "version.txt"), FileMode.Create))
await using (var writer = new StreamWriter(versionFile))
{
await writer.WriteLineAsync(typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown");
}

foreach (DirType type in Enum.GetValues<DirType>())
{
var path = Path.Combine(Base, type.ToString().ToLower());
var path = Path.Combine(_base, type.ToString().ToLower());
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
}
Expand All @@ -57,7 +57,7 @@ await using (var writer = new StreamWriter(versionFile))
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
static string GetDir(DirType type) => Path.Combine(Base, type.ToString().ToLower());
static string GetDir(DirType type) => Path.Combine(_base, type.ToString().ToLower());

/// <summary>
/// 获取文件夹内容
Expand Down

0 comments on commit 0810efd

Please sign in to comment.