nyan icon indicating copy to clipboard operation
nyan copied to clipboard

File API

Open heinezen opened this issue 3 years ago • 2 comments

nyan should provide a file api that we can inherit from.

Then we can natively interface to the openage file abstraction and do not need to read the whole file in the engine. Basically a class nyan::Filesystem that is specialized by openage. Ideally, the returned file lazily accesses all data through openage::util::File.

heinezen avatar Mar 29 '21 21:03 heinezen

and in what place should this be done?

DavidRomanovizc avatar Oct 21 '21 16:10 DavidRomanovizc

Currently you pass a function to the Database initialization (db.load(), the filefetcher_t), which is passed to read files. When this is implemented, nyan would get passed an object of abstract type that provides file opening/reading features. This abstract type is then made concrete in openage by implementing it (i.e. a subclass) that calls to openage's filesystem abstraction features (but that doesn't concern this issue directly of course, since we only need to provide an api class). If we just want to replace the filefetcher_t for now, the simplest variant is:

class nyan::Filesystem {
public:
    virtual nyan::File open_file(const std::string &filename) = 0;
}

TheJJ avatar Oct 21 '21 22:10 TheJJ