aboutsummaryrefslogtreecommitdiff
path: root/src/Constants/BuildDirs.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Constants/BuildDirs.cs')
-rw-r--r--src/Constants/BuildDirs.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Constants/BuildDirs.cs b/src/Constants/BuildDirs.cs
new file mode 100644
index 0000000..78609f5
--- /dev/null
+++ b/src/Constants/BuildDirs.cs
@@ -0,0 +1,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;
+ }
+ }
+} \ No newline at end of file