- more file system refactoring.

* moved the sprite renaming out of the file system entirely into a caller-provided callback.
* renamed several functions to closer match the terms of a file system.
* moved the VM interface out of the implementation.
This commit is contained in:
Christoph Oelckers 2020-04-11 13:26:42 +02:00
parent 6bccde3b51
commit c1bb7de23a
61 changed files with 929 additions and 767 deletions

View file

@ -36,6 +36,8 @@
#include "cmdlib.h"
#include "findfile.h"
#include "files.h"
#include "md5.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -1032,3 +1034,36 @@ FString M_ZLibError(int zerr)
return errs[-zerr - 1];
}
}
void md5Update(FileReader& file, MD5Context& md5, unsigned len)
{
uint8_t readbuf[8192];
unsigned t;
while (len > 0)
{
t = std::min<unsigned>(len, sizeof(readbuf));
len -= t;
t = (long)file.Read(readbuf, t);
md5.Update(readbuf, t);
}
}
//==========================================================================
//
// uppercoppy
//
// [RH] Copy up to 8 chars, upper-casing them in the process
//==========================================================================
void uppercopy(char* to, const char* from)
{
int i;
for (i = 0; i < 8 && from[i]; i++)
to[i] = toupper(from[i]);
for (; i < 8; i++)
to[i] = 0;
}

View file

@ -84,4 +84,10 @@ inline int32_t Scale(int32_t a, int32_t b, int32_t c)
return (int32_t)(((int64_t)a * b) / c);
}
class FileReader;
struct MD5Context;
void md5Update(FileReader& file, MD5Context& md5, unsigned len);
void uppercopy(char* to, const char* from);
#endif