aboutsummaryrefslogtreecommitdiff
path: root/src/Constants/BuildDirs.cs
blob: 78609f5001f7885eacf8ae3aa3937a80029f626f (plain)
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
using System;
using System.IO;

namespace VNLib.Tools.Build.Executor.Constants
{
    internal static class BuildDirs
    {  

        private static DirectoryInfo GetProjectDir()
        {
            //See if dir was specified on command line
            string[] args = Environment.GetCommandLineArgs();

            //Get the build dir
            DirectoryInfo dir = new(args.Length > 1 && Directory.Exists(args[1]) ? args[1] : Directory.GetCurrentDirectory());

            if (!dir.Exists)
            {
                dir.Create();
            }
            return dir;
        }

        public static DirectoryInfo GetOrCreateDir(string @default, string? other = null)
        {
            //Get the scratch dir
            DirectoryInfo logDir = new(Path.Combine(GetProjectDir().FullName, other?? @default));
            if (!logDir.Exists)
            {
                logDir.Create();
            }
            return logDir;
        }
    }
}