Skip to content

Commit

Permalink
libcore|FS: Manually populating a single native file
Browse files Browse the repository at this point in the history
DirectoryFeed is responsible for populating native files in FS2.
  • Loading branch information
skyjake committed Jan 6, 2017
1 parent 6bfd747 commit 12def49
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/directoryfeed.h
Expand Up @@ -105,6 +105,17 @@ class DENG2_PUBLIC DirectoryFeed : public Feed
*/
static File::Status fileStatus(NativePath const &nativePath);

/**
* Creates and interprets a single native file and adds it to a folder. The created
* file is not governed by any feed and will not be pruned during folder pruning.
*
* @param nativePath Native path of the source file.
* @param parentFolder Folder where to place the interpreted file.
*
* @return Reference to the interpreted file.
*/
static File &manuallyPopulateSingleFile(NativePath const &nativePath, Folder &parentFolder);

protected:
void populateSubFolder(Folder const &folder, String const &entryName);
void populateFile(Folder const &folder, String const &entryName, PopulatedFiles &populated);
Expand Down
14 changes: 14 additions & 0 deletions doomsday/sdk/libcore/src/filesys/directoryfeed.cpp
Expand Up @@ -266,3 +266,17 @@ File::Status DirectoryFeed::fileStatus(NativePath const &nativePath)
// Get file status information.
return File::Status(info.size(), info.lastModified());
}

File &DirectoryFeed::manuallyPopulateSingleFile(NativePath const &nativePath,
Folder &parentFolder)
{
File::Status const status = fileStatus(nativePath);

auto *source = new NativeFile(nativePath.fileName(), nativePath);
source->setStatus(status);

File *file = FileSystem::get().interpret(source);
parentFolder.add(file);
FileSystem::get().index(*file);
return *file;
}

0 comments on commit 12def49

Please sign in to comment.