Skip to content

Commit

Permalink
libcore|FS: Populating a folder outside the file system
Browse files Browse the repository at this point in the history
One can now populate a folder without modifying the state of the main
file system. This is useful for locally created or temporary folders
that don't need to interact with the rest of the system.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 20e7eb2 commit dc3327b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion doomsday/libs/core/include/de/filesys/folder.h
Expand Up @@ -75,7 +75,8 @@ class DE_PUBLIC Folder : public File
PopulateAsync = 0x4, ///< Do not block until complete.
PopulateAsyncFullTree = PopulateAsync | PopulateFullTree,

DisableNotification = 0x1000, // internal use
DisableNotification = 0x1000, // internal use: population audience not notified
DisableIndexing = 0x2000, // internal use: file is not added to the FS index
};
using PopulationBehaviors = Flags;

Expand Down
5 changes: 3 additions & 2 deletions doomsday/libs/core/src/filesys/directoryfeed.cpp
Expand Up @@ -40,10 +40,11 @@ DE_PIMPL_NOREF(DirectoryFeed)
String namePattern;
};

DirectoryFeed::DirectoryFeed(NativePath const &nativePath, Flags const &mode)
DirectoryFeed::DirectoryFeed(const NativePath &nativePath, Flags const &mode)
: d(new Impl)
{
debug("[DirectoryFeed] %s", nativePath.c_str());
LOG_AS("DirectoryFeed");
LOG_RES_VERBOSE("%s") << nativePath;
DE_ASSERT(!nativePath.toString().isEmpty());
d->nativePath = nativePath;
d->mode = mode;
Expand Down
15 changes: 12 additions & 3 deletions doomsday/libs/core/src/filesys/folder.cpp
Expand Up @@ -210,7 +210,10 @@ void Folder::clear()

void Folder::populate(PopulationBehaviors behavior)
{
fileSystem().changeBusyLevel(+1);
if (!behavior.testFlag(DisableIndexing))
{
fileSystem().changeBusyLevel(+1);
}

LOG_AS("Folder");
{
Expand Down Expand Up @@ -290,7 +293,10 @@ void Folder::populate(PopulationBehaviors behavior)
if (!d->contents.contains(i->name().lower()))
{
d->add(file.release());
fileSystem().index(*i);
if (!behavior.testFlag(DisableIndexing))
{
fileSystem().index(*i);
}
}
}
}
Expand All @@ -306,7 +312,10 @@ void Folder::populate(PopulationBehaviors behavior)
}
}

fileSystem().changeBusyLevel(-1);
if (!behavior.testFlag(DisableIndexing))
{
fileSystem().changeBusyLevel(-1);
}
};

if (internal::enableBackgroundPopulation)
Expand Down

0 comments on commit dc3327b

Please sign in to comment.