model/mpackage: introduce INI path related services
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 7 May 2018 17:56:44 +0000 (13:56 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 8 May 2018 16:56:26 +0000 (12:56 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/model/mpackage.nit

index d2f15dd..3157233 100644 (file)
@@ -77,6 +77,21 @@ class MPackage
                if path == null then return false
                return not path.has_suffix(".nit")
        end
+
+       # The path to `self` ini file
+       fun ini_path: nullable String do
+               var path = package_path
+               if path == null then return null
+               if is_expanded then return path / "package.ini"
+               return path.dirname / "{name}.ini"
+       end
+
+       # Does `self` have a ini file?
+       fun has_ini: Bool do
+               var ini_path = self.ini_path
+               if ini_path == null then return false
+               return ini_path.file_exists
+       end
 end
 
 # A group of modules in a package