diff --git a/source/dub/package_.d b/source/dub/package_.d index f843434..37f1eb6 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -41,16 +41,6 @@ PackageFormat format; } -struct PathAndFormat { - Path path; - PackageFormat format; - - @property bool empty() { return path.empty; } - - string toString() const { return path.toString(); } -} - - // Supported package descriptions in decreasing order of preference. static immutable FilenameAndFormat[] packageInfoFiles = [ {"dub.json", PackageFormat.json}, @@ -72,21 +62,21 @@ class Package { private { Path m_path; - PathAndFormat m_infoFile; + Path m_infoFile; PackageRecipe m_info; Package m_parentPackage; } - static PathAndFormat findPackageFile(Path path) + static Path findPackageFile(Path path) { foreach(file; packageInfoFiles) { auto filename = path ~ file.filename; - if(existsFile(filename)) return PathAndFormat(filename, file.format); + if(existsFile(filename)) return filename; } - return PathAndFormat(Path()); + return Path.init; } - this(Path root, PathAndFormat infoFile = PathAndFormat(), Package parent = null, string versionOverride = "") + this(Path root, Path infoFile = Path.init, Package parent = null, string versionOverride = "") { import dub.recipe.io; @@ -101,7 +91,7 @@ "No package file found in %s, expected one of %s" .format(root.toNativeString(), packageInfoFiles.map!(f => cast(string)f.filename).join("/"))); } - raw_package = readPackageRecipe(m_infoFile.path, parent ? parent.name : null); + raw_package = readPackageRecipe(m_infoFile, parent ? parent.name : null); } catch (Exception ex) throw ex;//throw new Exception(format("Failed to load package %s: %s", m_infoFile.toNativeString(), ex.msg)); this(raw_package, root, parent, versionOverride); @@ -155,7 +145,7 @@ @property void ver(Version ver) { assert(m_parentPackage is null); m_info.version_ = ver.toString(); } @property ref inout(PackageRecipe) info() inout { return m_info; } @property Path path() const { return m_path; } - @property Path packageInfoFilename() const { return m_infoFile.path; } + @property Path packageInfoFilename() const { return m_infoFile; } @property const(Dependency[string]) dependencies() const { return m_info.dependencies; } @property inout(Package) basePackage() inout { return m_parentPackage ? m_parentPackage.basePackage : this; } @property inout(Package) parentPackage() inout { return m_parentPackage; } @@ -188,7 +178,7 @@ void storeInfo() { storeInfo(m_path); - m_infoFile = PathAndFormat(m_path ~ defaultPackageFilename); + m_infoFile = m_path ~ defaultPackageFilename; } /// ditto void storeInfo(Path path) diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index aa5f921..75bb95a 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -152,7 +152,7 @@ return null; } - Package getOrLoadPackage(Path path, PathAndFormat infoFile = PathAndFormat(), bool allow_sub_packages = false) + Package getOrLoadPackage(Path path, Path infoFile = Path.init, bool allow_sub_packages = false) { path.endsWithSlash = true; foreach (p; getPackageIterator()) @@ -363,7 +363,7 @@ logDiagnostic("%s file(s) copied.", to!string(countFiles)); // overwrite dub.json (this one includes a version field) - auto pack = new Package(destination, PathAndFormat(), null, package_info["version"].get!string); + auto pack = new Package(destination, Path.init, null, package_info["version"].get!string); if (pack.packageInfoFilename.head != defaultPackageFilename) // Storeinfo saved a default file, this could be different to the file from the zip. @@ -691,7 +691,7 @@ logError("Package %s declared a sub-package, definition file is missing: %s", pack.name, path.toNativeString()); continue; } - sp = new Package(path, PathAndFormat(), pack); + sp = new Package(path, Path.init, pack); } else sp = new Package(spr.recipe, pack.path, pack); // Add the subpackage. diff --git a/source/dub/project.d b/source/dub/project.d index 5056a0e..f01da00 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -267,7 +267,7 @@ else { auto path = vspec.path; if (!path.absolute) path = m_rootPackage.path ~ path; - p = m_packageManager.getOrLoadPackage(path, PathAndFormat.init, true); + p = m_packageManager.getOrLoadPackage(path, Path.init, true); } } else if (m_dependencies.canFind!(d => getBasePackageName(d.name) == basename)) { auto idx = m_dependencies.countUntil!(d => getBasePackageName(d.name) == basename); @@ -283,7 +283,7 @@ Path path = vspec.path; if (!path.absolute) path = pack.path ~ path; logDiagnostic("%sAdding local %s", indent, path); - p = m_packageManager.getOrLoadPackage(path, PathAndFormat.init, true); + p = m_packageManager.getOrLoadPackage(path, Path.init, true); if (p.parentPackage !is null) { logWarn("%sSub package %s must be referenced using the path to it's parent package.", indent, name); p = p.parentPackage;