[Scummvm-devel] File API
Max Horn
max at quendi.de
Fri Feb 6 07:36:19 CET 2004
Some things I forgot:
* convert file locations to strings and vice versa (e.g. on a POSIX
like system, convert it into a path, and vice versa). This is needed
for our config code.
* not sure how to cope with the "encoding" stuff needed by (at least)
SCUMM games. Easiest would be to keep that for the (read) file types.
Right now, File objects are reusable. I don't see any instances in the
code where that is necessary, though. Hence, instead of doing this:
File file;
file.open("path");
we could do
File file("path");
file.open();
To make that work, though, File would have to do voodoo and access the
FileManager, and all... so, maybe we'd end up with syntax like:
File *file = g_fileManager.open("path");
What I don't like about this that we loose the nice "auto-cleanup"
property of class File: that is, if you create a File instance on the
stack, it'll automatically be disposed (and thus, the file be closed)
when the scope is left. Hence, we might want to operate with a more
sophisticated approach, where class File is simply a "wrapper" around
the real File class and the FileManager... something like
class FileManager {
class File {
...
};
...
public:
File *open(const char *filename, AccessMode mode);
};
class File {
FileManager::File *realFile;
public:
File(const char * filename) { realFile = FileManager::open(path); }
// or, for 100% source compatibility:
File();
bool open(const char * filename, AccessMode mode);
};
That has the advantage of allowing us to keep the current syntax, but
of course is more complicated internally...
Cheers,
Max
More information about the Scummvm-devel
mailing list