// native fprintf(file, const fmt[], any:...); static cell AMX_NATIVE_CALL amx_fprintf(AMX *amx, cell *params) { FileObject* fp = reinterpret_cast<FileObject*>(params[1]); if (!fp) { return 0; } int length; const char* string = format_amxstring(amx, params, 2, length); if (ValveFile *vfile = fp->AsValveFile()) { return g_FileSystem->FPrintf(vfile->handle(), const_cast<char*>("%s"), string); } else if (SystemFile *sysfile = fp->AsSystemFile()) { return fprintf(sysfile->handle(), "%s", string); } else { assert(false); } return 0; }
//native ungetc(file, data); static cell AMX_NATIVE_CALL amx_ungetc(AMX *amx, cell *params) { FileObject* fp = reinterpret_cast<FileObject*>(params[1]); if (!fp) { return 0; } SystemFile* sysfile = fp->AsSystemFile(); if (!sysfile) { LogError(amx, AMX_ERR_NATIVE, "Can not ungetc to file in the Valve file system"); return 0; } return ungetc(static_cast<int>(params[2]), sysfile->handle()); }