working on rendering
This commit is contained in:
@@ -94,6 +94,12 @@ public:
|
||||
|
||||
return buffer;
|
||||
}
|
||||
virtual const char *ReadString( IFileHandle *pFile ) override {
|
||||
char *szString = (char*)V_malloc(Size(pFile)+1);
|
||||
Read(pFile, szString, Size(pFile));
|
||||
szString[Size(pFile)] = 0;
|
||||
return szString;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "tier2/ifilesystem.h"
|
||||
#include "tier1/interface.h"
|
||||
#include "tier0/lib.h"
|
||||
#include "errno.h"
|
||||
|
||||
class CLIBCFileHandle : public IFileHandle
|
||||
{
|
||||
@@ -29,6 +30,9 @@ public:
|
||||
case FILEMODE_READ:
|
||||
szOperation = "rb";
|
||||
break;
|
||||
case FILEMODE_WRITE:
|
||||
szOperation = "wb";
|
||||
break;
|
||||
default:
|
||||
V_printf("Operation is not supported\n");
|
||||
break;
|
||||
@@ -36,7 +40,10 @@ public:
|
||||
|
||||
pFile = V_fopen(szFileName, szOperation);
|
||||
if (!pFile)
|
||||
{
|
||||
Plat_FatalErrorFunc("Failed to open %s: %s\n",strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pHandle = new CLIBCFileHandle;
|
||||
pHandle->m_pFileSystem = this;
|
||||
@@ -48,7 +55,10 @@ public:
|
||||
}
|
||||
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) override
|
||||
{
|
||||
return 0;
|
||||
CLIBCFileHandle *pHandle = (CLIBCFileHandle*)pFile;
|
||||
if (!pHandle)
|
||||
return 0;
|
||||
return V_fwrite( pData, 1, nDataSize, pHandle->m_pFile);
|
||||
}
|
||||
virtual size_t Read( IFileHandle *pFile, void *pData, size_t nDataSize ) override
|
||||
{
|
||||
@@ -109,6 +119,7 @@ public:
|
||||
}
|
||||
|
||||
virtual CUtlBuffer<unsigned char> Read( IFileHandle *pFile ) override { return NULL; };
|
||||
virtual const char *ReadString( IFileHandle *pFile ) override { return NULL; };
|
||||
};
|
||||
|
||||
EXPOSE_FILESYSTEM(CLIBCFileSystem, "sysfs");
|
||||
|
||||
Reference in New Issue
Block a user