[haiku-development] Re: BPath::Append() resets the original path in case of failure.

  • From: Bruno Albuquerque <bga@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2009 12:42:29 -0300

Stephan Aßmus wrote:

This all becomes clear when reading through the BeBook documentation for BPath. So both the BeOS and Haiku version perform as documented. Append() is implemented via SetTo(). SetTo() is destructive even in case of error. It becomes a matter of liking (or not) the fact that Append() is destructive... and whether this can even be changed, or if this would break any existing apps.

Yes, but an append operation should not have the side-effect of an error resulting in the original object being cleared up. I am pretty sure that if we were coming with this API today, we would not do something like that.

That said, we may break code that rely on checking the path for being NULL after an append operation to determine error, but I would argue that this code is also broken (as it should check for the return value of Append() instead).

-Bruno

Other related posts: