while(a > 0 && FileName[a-1] != SLASH) a--;
memcpy(TempName, FileName, a);
strcpy(TempName+a, "XXXXXX");
mktemp(TempName);
mkstemp(TempName);
if(!TempName[0]) {
ErrFatal("Cannot find available temporary file name");
}