mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Rework osdfunc_fileinfo()
git-svn-id: https://svn.eduke32.com/eduke32@7150 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
14f1ea1c05
commit
a35ffd976f
1 changed files with 27 additions and 18 deletions
|
@ -270,52 +270,61 @@ static int osdfunc_echo(osdfuncparm_t const * const parm)
|
||||||
|
|
||||||
static int osdfunc_fileinfo(osdfuncparm_t const * const parm)
|
static int osdfunc_fileinfo(osdfuncparm_t const * const parm)
|
||||||
{
|
{
|
||||||
int32_t i,j;
|
|
||||||
|
|
||||||
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
|
||||||
|
|
||||||
if ((i = kopen4load(parm->parms[0],0)) < 0)
|
int32_t h;
|
||||||
|
|
||||||
|
if ((h = kopen4load(parm->parms[0],0)) < 0)
|
||||||
{
|
{
|
||||||
OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]);
|
OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]);
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[256];
|
int32_t crctime = timerGetTicks();
|
||||||
uint32_t length = kfilelength(i);
|
uint32_t crcval = 0;
|
||||||
int32_t crctime = timerGetTicks();
|
int32_t siz = 0;
|
||||||
uint32_t crc = 0;
|
|
||||||
|
static constexpr int ReadSize = 65536;
|
||||||
|
auto *buf = (uint8_t *)Xmalloc(ReadSize);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
j = kread(i,buf,256);
|
siz = kread(h, buf, ReadSize);
|
||||||
crc = Bcrc32((uint8_t *)buf,j,crc);
|
crcval = Bcrc32((uint8_t *)buf, siz, crcval);
|
||||||
}
|
}
|
||||||
while (j == 256);
|
while (siz == ReadSize);
|
||||||
|
|
||||||
crctime = timerGetTicks() - crctime;
|
crctime = timerGetTicks() - crctime;
|
||||||
|
|
||||||
klseek(i, 0, BSEEK_SET);
|
klseek(h, 0, BSEEK_SET);
|
||||||
|
|
||||||
int32_t xxhtime = timerGetTicks();
|
int32_t xxhtime = timerGetTicks();
|
||||||
|
|
||||||
XXH32_state_t xxh;
|
XXH32_state_t xxh;
|
||||||
XXH32_reset(&xxh, 0x1337);
|
XXH32_reset(&xxh, 0x1337);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
j = kread(i, buf, 256);
|
siz = kread(h, buf, ReadSize);
|
||||||
XXH32_update(&xxh, (uint8_t *) buf, j);
|
XXH32_update(&xxh, (uint8_t *)buf, siz);
|
||||||
}
|
}
|
||||||
while (j == 256);
|
while (siz == ReadSize);
|
||||||
uint32_t xxhash = XXH32_digest(&xxh);
|
|
||||||
|
uint32_t const xxhash = XXH32_digest(&xxh);
|
||||||
xxhtime = timerGetTicks() - xxhtime;
|
xxhtime = timerGetTicks() - xxhtime;
|
||||||
|
|
||||||
kclose(i);
|
Bfree(buf);
|
||||||
|
|
||||||
OSD_Printf("fileinfo: %s\n"
|
OSD_Printf("fileinfo: %s\n"
|
||||||
" File size: %d\n"
|
" File size: %d\n"
|
||||||
" CRC-32: %08X (%g sec)\n"
|
" CRC-32: %08X (%g sec)\n"
|
||||||
" xxHash: %08X (%g sec)\n",
|
" xxHash: %08X (%g sec)\n",
|
||||||
parm->parms[0], length,
|
parm->parms[0], kfilelength(h),
|
||||||
crc, (double)crctime/timerGetFreq(),
|
crcval, (double)crctime/timerGetFreq(),
|
||||||
xxhash, (double)xxhtime/timerGetFreq());
|
xxhash, (double)xxhtime/timerGetFreq());
|
||||||
|
|
||||||
|
kclose(h);
|
||||||
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue