Skip to content

Commit

Permalink
libcore|FS: Improvements to DirectoryFeed
Browse files Browse the repository at this point in the history
Manually populating a .pack takes into account the possible container
folder structure, and the file type (file/folder) is checked when
the file status is updated.
  • Loading branch information
skyjake committed Jan 6, 2017
1 parent a5c8a86 commit ac19921
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions doomsday/sdk/libcore/src/filesys/directoryfeed.cpp
Expand Up @@ -264,19 +264,56 @@ File::Status DirectoryFeed::fileStatus(NativePath const &nativePath)
}

// Get file status information.
return File::Status(info.size(), info.lastModified());
return File::Status(info.isDir()? File::Status::FOLDER : File::Status::FILE,
dsize(info.size()),
info.lastModified());
}

File &DirectoryFeed::manuallyPopulateSingleFile(NativePath const &nativePath,
Folder &parentFolder)
{
Folder *parent = &parentFolder;

File::Status const status = fileStatus(nativePath);

auto *source = new NativeFile(nativePath.fileName(), nativePath);
source->setStatus(status);
// If we're populating a .pack, the possible container .packs must be included as
// parent folders (in structure only, not all their contents). Otherwise the .pack
// identifier would not be the same.

if (parentFolder.extension() != ".pack" &&
nativePath.fileName().fileNameExtension() == ".pack")
{
// Extract the portion of the path containing the parent .packs.
int const last = nativePath.segmentCount() - 1;
Rangei packRange(last, last);
while (packRange.start > 0 &&
nativePath.segment(packRange.start - 1).toStringRef()
.endsWith(".pack", Qt::CaseInsensitive))
{
packRange.start--;
}
if (!packRange.isEmpty())
{
parent = &FS::get().makeFolder(parentFolder.path() /
nativePath.subPath(packRange).withSeparators('/'),
FS::DontInheritFeeds);
}
}

File *file = FileSystem::get().interpret(source);
parentFolder.add(file);
FileSystem::get().index(*file);
return *file;
if (status.type() == File::Status::FILE)
{
auto *source = new NativeFile(nativePath.fileName(), nativePath);
source->setStatus(status);
File *file = FileSystem::get().interpret(source);
parent->add(file);
FileSystem::get().index(*file);
return *file;
}
else
{
return FS::get().makeFolderWithFeed(parent->path() / nativePath.fileName(),
new DirectoryFeed(nativePath),
Folder::PopulateFullTree,
FS::DontInheritFeeds | FS::PopulateNewFolder);
}
}

0 comments on commit ac19921

Please sign in to comment.