Move file management to its own class

This makes it possible to add support for delegates for file management
operations and on top makes it easier to add support for file management
operations on URLs.