[Scummvm-devel] Re: FilesystemNode specs

Marcus Comstedt marcus at mc.pp.se
Wed May 3 03:29:04 CEST 2006

Max Horn <max at quendi.de> writes:

> In all other scenarios I can imagine, you know in advance whether you
> want to get a file or a directory node. However, what happens if I
> try to get the file "00.LFL", but there is a directory with that name
> (due to malice or by accident)... Yeah, we don't have to gracefully
> handle all and every potential problem thrown us, but we should
> *handle* it nevertheless... In this particular case, see the above
> example, it asks whether node is valid (exists) and is a file. Of
> course we can remove those checks, and instead rely on File::open to
> return an error if the node is invalid. That's fine by me, too, but
> then we must make sure File::open resp. fopen handle this correctly.
> Not really a problem I guess -- it just should be written into the
> specs (doxygen comments) of all involved methods.

Personally, I don't think

FSNode x = y.getChild("00.LFL");
else if(x.isDirectory())
else if(!x.open())

is better than

FSNode x = y.getChild("00.LFL");

If there isn't any reason to handle the different kinds of errors in
different ways, there is no reason why the client should have to do
multiple checks.  It just makes it easier to forget to make one of the

There should be a way for open() to give some indication as to what
went wrong though.

  // Marcus

More information about the Scummvm-devel mailing list