mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Added base64 support for FileData, and inlined all resources in boot.lua/graphics.lua as base64. Also removed old reshax stuff.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <common/config.h>
|
||||
|
||||
#include <common/utf8.h>
|
||||
#include <common/b64.h>
|
||||
|
||||
#include "Filesystem.h"
|
||||
|
||||
@@ -146,12 +147,26 @@ namespace physfs
|
||||
{
|
||||
FileData * fd = new FileData(size, std::string(filename));
|
||||
|
||||
// Copy the data into
|
||||
// Copy the data into FileData.
|
||||
memcpy(fd->getData(), data, size);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
FileData * Filesystem::newFileData(const char * b64, const char * filename)
|
||||
{
|
||||
int size = strlen(b64);
|
||||
int outsize = 0;
|
||||
char * dst = b64_decode(b64, size, outsize);
|
||||
FileData * fd = new FileData(outsize, std::string(filename));
|
||||
|
||||
// Copy the data into FileData.
|
||||
memcpy(fd->getData(), dst, outsize);
|
||||
delete [] dst;
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
const char * Filesystem::getWorkingDirectory()
|
||||
{
|
||||
if(cwd.empty())
|
||||
|
||||
@@ -142,6 +142,12 @@ namespace physfs
|
||||
**/
|
||||
FileData * newFileData(void * data, int size, const char * filename);
|
||||
|
||||
/**
|
||||
* Creates a new FileData object from base64 data.
|
||||
* @param b64 The base64 data.
|
||||
**/
|
||||
FileData * newFileData(const char * b64, const char * filename);
|
||||
|
||||
/**
|
||||
* Gets the current working directory.
|
||||
**/
|
||||
|
||||
@@ -98,8 +98,26 @@ namespace physfs
|
||||
size_t length = 0;
|
||||
const char * str = lua_tolstring(L, 1, &length);
|
||||
const char * filename = lua_tostring(L, 2);
|
||||
const char * decstr = lua_isstring(L, 3) ? lua_tostring(L, 3) : 0;
|
||||
|
||||
FileData * t = instance->newFileData((void*)str, (int)length, filename);
|
||||
FileData::Decoder decoder = FileData::FILE;
|
||||
|
||||
if(decstr)
|
||||
FileData::getConstant(decstr, decoder);
|
||||
|
||||
FileData * t = 0;
|
||||
|
||||
switch(decoder)
|
||||
{
|
||||
case FileData::FILE:
|
||||
t = instance->newFileData((void*)str, (int)length, filename);
|
||||
break;
|
||||
case FileData::BASE64:
|
||||
t = instance->newFileData(str, filename);
|
||||
break;
|
||||
default:
|
||||
return luaL_error(L, "Unrecognized FileData decoder: %s", decstr);
|
||||
}
|
||||
|
||||
luax_newtype(L, "FileData", FILESYSTEM_FILE_DATA_T, (void*)t);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user