[physfs] PHYSFS_stat/HG & Numerical Errorcode

Christoph Nelles evilazrael at evilazrael.de
Wed Feb 17 18:49:07 EST 2010


thanks for the steps. It worked. I've read The Definitive Guide to
mercurial book but real workflows besides the (stupid) examples are
still a mystery to me. I am happily using SVN for years now, that's
somehow easier *g*

In platform_windows.c in line 1497 you forgot the pointer to the stat:
filesize = (((PHYSFS_uint64) winstat.nFileSizeHigh) << 32) |
right is:
stat->filesize = (((PHYSFS_uint64) winstat.nFileSizeHigh) << 32) |

Am 17.02.2010 02:52, schrieb Ryan C. Gordon:
> ...then do the "merge" which in this case is "take Ryan's changes no
>  matter what"...
> HGMERGE='sh -c "cp \$2 \$0"' hg merge

HGMERGE='sh -c "cp $2 $1"' hg merge
worked for me ;)

> [ui] username = My Full Name <user at example.com>

I've set this but HGEclipse somehow ignored the value. But i've found
the option.

> ...as this is what gets associated with your commits.

In HGEclipse this presetting was gloriously named "Mercurial username"
and i thought of a technical user name.

The graph looks weird:
Looks like your default branch will become a different branch in my

> I cloned my working copy, experimented, deleted it, and recloned
> like 18 times writing this. 

As you take this work so lightly could you please take a look at my
ErrorCode branch and tell me if you like the idea? It's a work in
progress and i've made a few new files so i have a clearer work area,
they can be merged later.

Look at physfs_languages.c and physfs_errorcodes.h.
I've put the constants from the error messages #defines into an enum
PHYSFS_Errorcode, with ERR_NO_ERROR = 0 and ERR_OTHER_ERROR = 1 and the
rest following.
In the struct ErrStatus i changed the int errorAvailable member to
PHYSFS_Errorcode and kept the errorMessage string. The previous
__PHYSFS_setError function was split into __PHYSFS_setErrorCode(code)
which sets a specific code and the message to "" and
__PHYSFS_setErrorMessage(message) which sets the errorcode to
ERR_OTHER_ERROR and errorMessage to the passed in string.

The function PHYSFS_GetLastErrorCode() simply gets the current code and
resets it to OK. The function PHYSFS_GetLastError() behaves like the
current one and returns the appropriate ErrorMessage, either by looking
the correct message or by returning the custom message in the case of

Message and language lookup. This is now dynamic and not fixed at
compile time. The struct ErrorMessage consists of a code and a message.
For each lnaguage there is an array with messages like
errorMessagesEnglish[] =
{ERR_NO_ERROR, "No Error"},

There is an at runtime settable default language which will be used then
no specific language was requested and a fallback language which will be
used if a message is not translated to the requested language.
So you may set the default language to e.g. German, get an error and
still get the english message if there is no german translation yet.
So there are two extra public functions:
PHYSFS_getErrorMessage(code) which returns the message in the default
language or in the fallback language in the case the message was not
PHYSFS_getErrorMessageLocalized(language, code) which let you request a
specific language.

This allows you to give the user a translated message and e.g. log a
standard (english) message to a protocol.

I changed all the BAIL Macros in the code to _CODE and _MSG and a silent
one. Often the message parameter was null resulting in an unnecesary
call to SetError() which returned immediately in this case.

What is your opinion on this?

Further questions:
- Perhaps replacing ERR_OTHER_ERROR to ERR_CUSTOM_MIN to 32000 or so for
future use in plugins would be useful, so people can set their own
errors with user defined messages
- A smaller more common subset of errors could be placed at the
beginning and the existing code be checked if more general errors are
- No translation support for these custom error messages
- The archiver description is hardcoded at the moment, this may be
changed in a similar fashion, but in my eyes this is a technical
description and could be dropped in favor of the english text.

Christoph Nelles

E-Mail    : evilazrael at evilazrael.de
Jabber    : eazrael at evilazrael.net      ICQ       : 78819723

PGP-Key   : ID 0x424FB55B on subkeys.pgp.net
            or http://evilazrael.net/pgp.txt

More information about the physfs mailing list