Skip to content

Commit

Permalink
libcore|FS: Utility method added
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 13, 2017
1 parent 6f0dac7 commit 0b59393
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/dialogs/packageinfodialog.cpp
Expand Up @@ -196,7 +196,7 @@ DENG_GUI_PIMPL(PackageInfoDialog)
foreach (String ext, imageExts)
{
String const imgPath = packagePath / "icon" + ext;
if (ImageFile const *img = FS::get().root().tryLocate<ImageFile const>(imgPath))
if (ImageFile const *img = FS::tryLocate<ImageFile const>(imgPath))
{
Image iconImage = img->image();
if (iconImage.width() > 512 || iconImage.height() > 512)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/home/savelistwidget.cpp
Expand Up @@ -82,7 +82,7 @@ DENG_GUI_PIMPL(SaveListWidget)
auto const &saveItem = d->self().organizer()
.findItemForWidget(saveButton)->as<SaveListData::SaveItem>();

if (GameStateFolder const *saved = FS::get().root().tryLocate<GameStateFolder>(saveItem.savePath()))
if (GameStateFolder const *saved = FS::tryLocate<GameStateFolder>(saveItem.savePath()))
{
auto *docPop = new DocumentPopupWidget;
docPop->setDeleteAfterDismissed(true);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/apps/libdoomsday/src/savegames.cpp
Expand Up @@ -161,7 +161,7 @@ DENG2_PIMPL(SaveGames)
{
LOG_AS("SaveGames");
String const legacySavePath = String("/sys/legacysavegames") / gameId;
if (Folder *oldSaveFolder = FileSystem::get().root().tryLocate<Folder>(legacySavePath))
if (Folder *oldSaveFolder = FileSystem::tryLocate<Folder>(legacySavePath))
{
// Add any new legacy savegames which may have appeared in this folder.
oldSaveFolder->populate(Folder::PopulateOnlyThisFolder /* no need to go deep */);
Expand Down Expand Up @@ -280,7 +280,7 @@ D_CMD(InspectSavegame)
savePath = AbstractSession::savePath() / savePath;
}

if (GameStateFolder const *saved = FileSystem::get().root().tryLocate<GameStateFolder>(savePath))
if (GameStateFolder const *saved = FileSystem::tryLocate<GameStateFolder>(savePath))
{
LOG_SCR_MSG("%s") << saved->metadata().asStyledText();
LOG_SCR_MSG(_E(D) "Resource: " _E(.)_E(i) "\"%s\"") << saved->path();
Expand Down
5 changes: 5 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/filesystem.h
Expand Up @@ -356,6 +356,11 @@ class DENG2_PUBLIC FileSystem : public System
return FileSystem::get().root().locate<T>(path);
}

template <typename T>
static T *tryLocate(String const &path) {
return FileSystem::get().root().tryLocate<T>(path);
}

private:
DENG2_PRIVATE(d)
};
Expand Down

0 comments on commit 0b59393

Please sign in to comment.