Skip to content

Commit

Permalink
libcore|FS: Utility method for adding new package dependencies
Browse files Browse the repository at this point in the history
Modifying the metadata of unloaded packages is part of the
responsibilities of the Package class.
  • Loading branch information
skyjake committed Jun 4, 2016
1 parent 9527e90 commit b6dd7a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/package.h
Expand Up @@ -172,6 +172,8 @@ class DENG2_PUBLIC Package : public IObject

static StringList requires(File const &packageFile);

static void addRequiredPackage(File &packageFile, String const &id);

/**
* Splits a string containing a package identifier and version. The
* expected format of the string is `{packageId}_{version}`.
Expand Down
14 changes: 14 additions & 0 deletions doomsday/sdk/libcore/src/filesys/package.cpp
Expand Up @@ -351,6 +351,20 @@ StringList Package::requires(File const &packageFile)
return ids;
}

void Package::addRequiredPackage(File &packageFile, String const &id)
{
Record &names = packageFile.objectNamespace();

if (!names.has(PACKAGE_REQUIRES))
{
names.addArray(PACKAGE_REQUIRES, new ArrayValue({ new TextValue(id) }));
}
else
{
names[PACKAGE_REQUIRES].value<ArrayValue>().add(new TextValue(id));
}
}

static String stripAfterFirstUnderscore(String str)
{
int pos = str.indexOf('_');
Expand Down

0 comments on commit b6dd7a4

Please sign in to comment.