Skip to content

Commit

Permalink
- more file system refactoring.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
coelckers committed Apr 11, 2020
1 parent 6bccde3 commit c1bb7de
Show file tree
Hide file tree
Showing 61 changed files with 927 additions and 765 deletions.
35 changes: 35 additions & 0 deletions src/common/utility/cmdlib.cpp
Expand Up @@ -36,6 +36,8 @@

#include "cmdlib.h"
#include "findfile.h"
#include "files.h"
#include "md5.h"

#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -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;
}

6 changes: 6 additions & 0 deletions src/common/utility/cmdlib.h
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/console/c_cmds.cpp
Expand Up @@ -848,7 +848,7 @@ CCMD (wdir)
Printf ("usage: wdir <wadfile>\n");
return;
}
int wadnum = fileSystem.CheckIfWadLoaded (argv[1]);
int wadnum = fileSystem.CheckIfResourceFileLoaded (argv[1]);
if (wadnum < 0)
{
Printf ("%s must be loaded to view its directory.\n", argv[1]);
Expand Down
3 changes: 1 addition & 2 deletions src/d_iwad.cpp
Expand Up @@ -270,11 +270,10 @@ FIWadManager::FIWadManager(const char *firstfn, const char *optfn)
{
FileSystem check;
TArray<FString> fns;
TArray<FString> deletes;
fns.Push(firstfn);
if (optfn) fns.Push(optfn);

check.InitMultipleFiles(fns, deletes, true);
check.InitMultipleFiles(fns, true);
if (check.GetNumLumps() > 0)
{
int num = check.CheckNumForName("IWADINFO");
Expand Down

0 comments on commit c1bb7de

Please sign in to comment.