mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
- handled all other uses of fopen that could reasonably converted to FileReader or FileWriter.
This commit is contained in:
parent
4003e7ca11
commit
7d0759e2fa
5 changed files with 20 additions and 20 deletions
|
@ -2488,17 +2488,16 @@ bool D_LoadDehLump(int lumpnum)
|
|||
|
||||
bool D_LoadDehFile(const char *patchfile)
|
||||
{
|
||||
FILE *deh;
|
||||
FileReader fr;
|
||||
|
||||
deh = fopen(patchfile, "rb");
|
||||
if (deh != NULL)
|
||||
if (!fr.Open(patchfile))
|
||||
{
|
||||
PatchSize = Q_filelength(deh);
|
||||
PatchSize = fr.GetLength();
|
||||
|
||||
PatchName = copystring(patchfile);
|
||||
PatchFile = new char[PatchSize + 1];
|
||||
fread(PatchFile, 1, PatchSize, deh);
|
||||
fclose(deh);
|
||||
fr.Read(PatchFile, PatchSize);
|
||||
fr.Close();
|
||||
PatchFile[PatchSize] = '\0'; // terminate with a '\0' character
|
||||
return DoDehPatch();
|
||||
}
|
||||
|
|
|
@ -87,13 +87,18 @@ FileReader::FileReader (FILE *file, long length)
|
|||
FilePos = StartPos = ftell (file);
|
||||
}
|
||||
|
||||
FileReader::~FileReader ()
|
||||
FileReader::~FileReader()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void FileReader::Close()
|
||||
{
|
||||
if (CloseOnDestruct && File != NULL)
|
||||
{
|
||||
fclose (File);
|
||||
File = NULL;
|
||||
}
|
||||
File = NULL;
|
||||
}
|
||||
|
||||
bool FileReader::Open (const char *filename)
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
FileReader (FILE *file);
|
||||
FileReader (FILE *file, long length);
|
||||
bool Open (const char *filename);
|
||||
void Close();
|
||||
virtual ~FileReader ();
|
||||
|
||||
virtual long Tell () const;
|
||||
|
|
|
@ -122,22 +122,18 @@ void M_FindResponseFile (void)
|
|||
if (added_stuff < limit)
|
||||
{
|
||||
// READ THE RESPONSE FILE INTO MEMORY
|
||||
handle = fopen (Args->GetArg(i) + 1,"rb");
|
||||
if (!handle)
|
||||
FileReader fr;
|
||||
if (!fr.Open(Args->GetArg(i) + 1))
|
||||
{ // [RH] Make this a warning, not an error.
|
||||
Printf ("No such response file (%s)!\n", Args->GetArg(i) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf ("Found response file %s!\n", Args->GetArg(i) + 1);
|
||||
fseek (handle, 0, SEEK_END);
|
||||
size = ftell (handle);
|
||||
fseek (handle, 0, SEEK_SET);
|
||||
size = fr.GetLength();
|
||||
file = new char[size+1];
|
||||
fread (file, size, 1, handle);
|
||||
fr.Read (file, size);
|
||||
file[size] = 0;
|
||||
fclose (handle);
|
||||
|
||||
argsize = ParseCommandLine (file, &argc, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,8 +269,8 @@ CCMD (md5sum)
|
|||
}
|
||||
for (int i = 1; i < argv.argc(); ++i)
|
||||
{
|
||||
FILE *file = fopen(argv[i], "rb");
|
||||
if (file == NULL)
|
||||
FileReader fr;
|
||||
if (!fr.Open(argv[i]))
|
||||
{
|
||||
Printf("%s: %s\n", argv[i], strerror(errno));
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ CCMD (md5sum)
|
|||
uint8_t readbuf[8192];
|
||||
size_t len;
|
||||
|
||||
while ((len = fread(readbuf, 1, sizeof(readbuf), file)) > 0)
|
||||
while ((len = fr.Read(readbuf, sizeof(readbuf))) > 0)
|
||||
{
|
||||
md5.Update(readbuf, (unsigned int)len);
|
||||
}
|
||||
|
@ -290,7 +290,6 @@ CCMD (md5sum)
|
|||
Printf("%02x", readbuf[j]);
|
||||
}
|
||||
Printf(" *%s\n", argv[i]);
|
||||
fclose (file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue