diff trunk/src/dil/SettingsLoader.d @ 721:8955296dd807

Added ddoc_files option to config.d
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 01 Feb 2008 16:40:35 +0100
parents 170ddcdc9711
children ca7607226caa
line wrap: on
line diff
--- a/trunk/src/dil/SettingsLoader.d	Fri Feb 01 15:40:32 2008 +0100
+++ b/trunk/src/dil/SettingsLoader.d	Fri Feb 01 16:40:35 2008 +0100
@@ -15,9 +15,10 @@
 void loadSettings()
 {
   scope execPath = new FilePath(GetExecutableFilePath());
+  execPath = new FilePath(execPath.folder());
 
   // Load config.d
-  auto filePath = execPath.file("config.d").toString();
+  auto filePath = resolvePath(execPath, "config.d");
   auto modul = new Module(filePath);
   modul.parse();
 
@@ -51,6 +52,16 @@
       else
         throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer.");
       break;
+    case "ddoc_files":
+      if (auto array = e.Is!(ArrayInitExpression))
+      {
+        foreach (value; array.values)
+          if (auto str = value.Is!(StringExpression))
+            GlobalSettings.ddocFilePaths ~= str.getString();
+      }
+      else
+        throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer.");
+      break;
     case "lexer_error":
       if (auto val = e.Is!(StringExpression))
         GlobalSettings.lexerErrorFormat = val.getString();
@@ -68,7 +79,7 @@
   }
 
   // Load language file.
-  filePath = execPath.file(GlobalSettings.langFile).toString();
+  filePath = resolvePath(execPath, GlobalSettings.langFile);
   modul = new Module(filePath);
   modul.parse();
 
@@ -118,6 +129,13 @@
   dil.Messages.SetMessages(messages);
 }
 
+string resolvePath(FilePath execPath, string filePath)
+{
+  if ((new FilePath(filePath)).isAbsolute())
+    return filePath;
+  return execPath.dup.append(filePath).toString();
+}
+
 version(Windows)
 {
 private extern(Windows) uint GetModuleFileNameA(void*, char*, uint);