remove explicit filesystem dependency

This commit is contained in:
Jeremie Roy 2013-05-07 14:26:49 +02:00
parent e4712b2641
commit d470ac2567
2 changed files with 31 additions and 31 deletions

View file

@ -12,7 +12,38 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
static const char* s_shaderPath = NULL; static const char* s_shaderPath = NULL;
long int fsize(FILE* _file)
{
long int pos = ftell(_file);
fseek(_file, 0L, SEEK_END);
long int size = ftell(_file);
fseek(_file, pos, SEEK_SET);
return size;
}
static const bgfx::Memory* loadShader(const char* _shaderPath, const char* _shaderName)
{
char out[512];
strcpy(out, _shaderPath);
strcat(out, _shaderName);
strcat(out, ".bin");
FILE* file = fopen(out, "rb");
if (NULL != file)
{
uint32_t size = (uint32_t)fsize(file);
const bgfx::Memory* mem = bgfx::alloc(size+1);
/*size_t ignore =*/ fread(mem->data, 1, size, file);
/*BX_UNUSED(ignore);*/
fclose(file);
mem->data[mem->size-1] = '\0';
return mem;
}
return NULL;
}
int _main_(int /*_argc*/, char** /*_argv*/) int _main_(int /*_argc*/, char** /*_argv*/)
{ {

View file

@ -13,37 +13,6 @@
#define MAX_TEXT_BUFFER_COUNT 64 #define MAX_TEXT_BUFFER_COUNT 64
#define MAX_BUFFERED_CHARACTERS 8192 #define MAX_BUFFERED_CHARACTERS 8192
long int fsize(FILE* _file)
{
long int pos = ftell(_file);
fseek(_file, 0L, SEEK_END);
long int size = ftell(_file);
fseek(_file, pos, SEEK_SET);
return size;
}
static const bgfx::Memory* loadShader(const char* _shaderPath, const char* _shaderName)
{
char out[512];
strcpy(out, _shaderPath);
strcat(out, _shaderName);
strcat(out, ".bin");
FILE* file = fopen(out, "rb");
if (NULL != file)
{
uint32_t size = (uint32_t)fsize(file);
const bgfx::Memory* mem = bgfx::alloc(size+1);
/*size_t ignore =*/ fread(mem->data, 1, size, file);
/*BX_UNUSED(ignore);*/
fclose(file);
mem->data[mem->size-1] = '\0';
return mem;
}
return NULL;
}
// Table from Flexible and Economical UTF-8 Decoder // Table from Flexible and Economical UTF-8 Decoder
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> // Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. // See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.