Q:

Best string hashing function for short filenames

What would be the best string hashing function for say filename like strings?
The strings would be similar to:
pics/test.pic
maps/test.map
materials/metal.mtl

A:

If the nature of data to be hashed doesn't require any fancy hashing algorithms, like the nature of textual strings, you may want to try the FNV hashing function. The FNV hash, short for Fowler/Noll/Vo in honor of the creators, is a very fast algorithm that has been used in many applications with wonderful results, and for its simplicity, the FNV hash should be one of the first hashes tried in an application.
unsigned int fnv_hash (void* key, int len)
{
    unsigned char* p = key;
    unsigned int h = 2166136261;
    int i;

    for (i = 0; i < len; i++)
        h = (h*16777619) ^ p[i];

    return h;
}

Or roll with MD5 algorithm instead, which is general-purpose and thus covers your needs quite well.

