Is there a way to implement your own FileManager (or FilePak) and replace FileManagerGeneric?

Hi,

Our updater needs to be able to update files in PAKs (or similiar), but FilePak doesn’t allow deleting or changing a FPakEntry so we would only be able to add files. I guess we can easily change this (possibly cast away the const), but I would like to avoid making changes in UE4 source files to make migrating to future releases easier.

So my question is: is there a way to override FileManager (so we could use our own package file format for all disk access) or possibly implement our own alternative to FilePak without changing too much of the UE4 source? As far as I can tell these are tied quite deeply into the core and they’re not (yet, anyway) very modular.

Any suggestions would be appreciated!

Actually, I just noticed the way you save the header isn’t strictly enforced by FilePak but the user. (UnrealPak in my case) so it might just work to mark deleted file entries by setting the compression flag to something special, and then that empty space can be reused when inserting new files.

I’ll give this a try!

Actually, UnrealPak does support adding files out of the box. It just doesn’t support deleting or modifying existing files.

I’ll take a look at the code you mentioned. Thanks JoJo, I really appreciate the input!

Hi,

The pak file stuff is written as a module so it should be possible to do what you want with no code changes. Have a look at FPlatformManager::SetPlatformFile(IPlatformFile&), FPlatformManager::GetPlatformFile(const TCHAR*) and what the ConditionallyCreateFileWrapper() & LaunchCheckForFileOverride() functions are doing. Those functions and the original PakFile module should give you a good example of what you need to do to get your own version working.

I wouldn’t suggest trying to modify Pak file system to support writing or adding files. The way Pak files work means that that’s not a simple task at all. I don’t think they were ever suppose be anything other than read-only :slight_smile:

Couple notes:

  • You don’t technically need to use .pak files, although our packaging will use them by default. You can package up a game without pak files if you use UnrealFrontend or the GameLauncher (still experimental in the editor).
  • That way you could use your own file system/manager/etc
  • We are currently working on our patching system, but the idea there is that you would have your “shipped” pak files (one pak per chunk, for staged downloading), and then each pak would have a patch .pak file, that would replace/add files in the shipped pak file. It isn’t designed to delete a shipped file - so it wouldn’t be ideal for games that want to replace a large part of the shipped assets (as you would double the size of your installed game). For that, you would want a more advanced patching system that doesn’t use .pak files, or enhances the .pak files to modify them on disk like you are looking at.

Hope that info helps!
Josh