Working on C tooling
This commit is contained in:
@ -32,6 +32,29 @@ char * assetStringLoad(char *assetName) {
|
||||
return str;
|
||||
}
|
||||
|
||||
uint8_t * assetRawLoad(char *assetName) {
|
||||
// Open a buffer.
|
||||
assetbuffer_t *fptr = assetBufferOpen(assetName);
|
||||
if(fptr == NULL) return NULL;
|
||||
|
||||
// Read the count of bytes in the file
|
||||
fseek(fptr, 0, SEEK_END);// Seek to the end
|
||||
size_t length = ftell(fptr);// Get our current position (the end)
|
||||
fseek(fptr, 0, SEEK_SET);// Reset the seek
|
||||
|
||||
// Create the string buffer
|
||||
uint8_t *str = malloc(length);
|
||||
if(str == NULL) {
|
||||
assetBufferClose(fptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Read and seal the string.
|
||||
fread(str, 1, length, fptr);// Read all the bytes
|
||||
assetBufferClose(fptr); // Close the buffer.
|
||||
return str;
|
||||
}
|
||||
|
||||
assetbuffer_t * assetBufferOpen(char *assetName) {
|
||||
// Get the directory based on the raw input by creating a new string.
|
||||
FILE *fptr;
|
||||
|
@ -27,6 +27,8 @@ typedef FILE assetbuffer_t;
|
||||
*/
|
||||
char * assetStringLoad(char *assetName);
|
||||
|
||||
uint8_t * assetRawLoad(char *assetName);
|
||||
|
||||
/**
|
||||
* Platform-centric method to open a file buffer to an asset.
|
||||
* @param assetName The asset name to open a buffer for.
|
||||
|
Reference in New Issue
Block a user