Skip to content

Instantly share code, notes, and snippets.

@thendrix
Last active May 6, 2017 11:56
Show Gist options
  • Save thendrix/858aa6c861aa6f916222174f1b26c4b6 to your computer and use it in GitHub Desktop.
Save thendrix/858aa6c861aa6f916222174f1b26c4b6 to your computer and use it in GitHub Desktop.
Use this to help purge the world of tempnam such as in FBX -- yes I tweeted this a while back
extern "C" {
// '-Wl,-wrap,tempnam'
char *__wrap_tempnam( const char *dir, const char *pfx )
{
// You'll have to rewrite this part for your filesystem layer.
static unsigned int i = 0;
const unsigned int len = 512;
char path[ len ];
KaFilePathToCachePathf( path, len, "%s%s-%d.tmp",
( dir != nullptr ) ? dir : "",
( pfx != nullptr ) ? pfx : "", i++ );
KaLogTagf( KaFbxImporter, ">>> %s\n", path );
char *s = (char*)malloc( len );
strncpy( s, path, len );
return s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment