- got rid of M_ReadFile(Malloc) which werew each used only once in the entire code. These were still using the low level POSIX-style file interface which shouldn't really be used anymore.
- let FScanner::OpenFile return an error instead of throwing an exception. The exception was never used anyway aside from being caught right away to be ignored.
This commit is contained in:
parent
e15b23f132
commit
838e52001c
8 changed files with 39 additions and 81 deletions
|
|
@ -244,18 +244,25 @@ void FScanner::Open (const char *name)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FScanner::OpenFile (const char *name)
|
||||
bool FScanner::OpenFile (const char *name)
|
||||
{
|
||||
uint8_t *filebuf;
|
||||
int filesize;
|
||||
|
||||
Close ();
|
||||
filesize = M_ReadFile (name, &filebuf);
|
||||
|
||||
FileReader fr(name);
|
||||
if (!fr.Open(name)) return false;
|
||||
auto filesize = fr.GetLength();
|
||||
auto filebuf = new uint8_t[filesize];
|
||||
if (fr.Read(filebuf, filesize) != filesize)
|
||||
{
|
||||
delete[] filebuf;
|
||||
return false;
|
||||
}
|
||||
ScriptBuffer = FString((const char *)filebuf, filesize);
|
||||
delete[] filebuf;
|
||||
ScriptName = name; // This is used for error messages so the full file name is preferable
|
||||
LumpNum = -1;
|
||||
PrepareScript ();
|
||||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue