Remove File.cpp
This commit is contained in:
parent
0faf06224f
commit
46b48510a8
3 changed files with 0 additions and 117 deletions
|
@ -289,9 +289,6 @@
|
|||
<File
|
||||
RelativePath="..\src\Fade.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\File.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Flags.cpp">
|
||||
</File>
|
||||
|
@ -507,9 +504,6 @@
|
|||
<File
|
||||
RelativePath="..\src\Fade.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\File.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\Flags.h">
|
||||
</File>
|
||||
|
|
96
src/File.cpp
96
src/File.cpp
|
@ -1,96 +0,0 @@
|
|||
#include "File.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
long LoadFileToMemory(const char *file_path, unsigned char **file_buffer)
|
||||
{
|
||||
long returned_size = -1;
|
||||
|
||||
FILE *file = fopen(file_path, "rb");
|
||||
|
||||
if (file != NULL)
|
||||
{
|
||||
if (!fseek(file, 0, SEEK_END))
|
||||
{
|
||||
const long file_size = ftell(file);
|
||||
|
||||
if (file_size >= 0)
|
||||
{
|
||||
rewind(file);
|
||||
*file_buffer = (unsigned char*)malloc(file_size);
|
||||
|
||||
if (*file_buffer != NULL)
|
||||
{
|
||||
if (fread(*file_buffer, file_size, 1, file) == 1)
|
||||
returned_size = file_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
return returned_size;
|
||||
}
|
||||
|
||||
unsigned short File_ReadBE16(FILE *stream)
|
||||
{
|
||||
unsigned char bytes[2];
|
||||
|
||||
fread(bytes, 2, 1, stream);
|
||||
|
||||
return (bytes[0] << 8) | bytes[1];
|
||||
}
|
||||
|
||||
unsigned long File_ReadBE32(FILE *stream)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
|
||||
fread(bytes, 4, 1, stream);
|
||||
|
||||
return (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
|
||||
}
|
||||
|
||||
unsigned short File_ReadLE16(FILE *stream)
|
||||
{
|
||||
unsigned char bytes[2];
|
||||
|
||||
fread(bytes, 2, 1, stream);
|
||||
|
||||
return (bytes[1] << 8) | bytes[0];
|
||||
}
|
||||
|
||||
unsigned long File_ReadLE32(FILE *stream)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
|
||||
fread(bytes, 4, 1, stream);
|
||||
|
||||
return (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
|
||||
}
|
||||
|
||||
void File_WriteBE16(unsigned short value, FILE *stream)
|
||||
{
|
||||
for (unsigned int i = 2; i-- != 0;)
|
||||
fputc(value >> (8 * i), stream);
|
||||
}
|
||||
|
||||
void File_WriteBE32(unsigned long value, FILE *stream)
|
||||
{
|
||||
for (unsigned int i = 4; i-- != 0;)
|
||||
fputc(value >> (8 * i), stream);
|
||||
}
|
||||
|
||||
void File_WriteLE16(unsigned short value, FILE *stream)
|
||||
{
|
||||
for (unsigned int i = 0; i < 2; ++i)
|
||||
fputc(value >> (8 * i), stream);
|
||||
}
|
||||
|
||||
void File_WriteLE32(unsigned long value, FILE *stream)
|
||||
{
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
fputc(value >> (8 * i), stream);
|
||||
}
|
15
src/File.h
15
src/File.h
|
@ -1,15 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
long LoadFileToMemory(const char *file_path, unsigned char **file_buffer);
|
||||
|
||||
unsigned short File_ReadBE16(FILE *stream);
|
||||
unsigned long File_ReadBE32(FILE *stream);
|
||||
unsigned short File_ReadLE16(FILE *stream);
|
||||
unsigned long File_ReadLE32(FILE *stream);
|
||||
|
||||
void File_WriteBE16(unsigned short value, FILE *stream);
|
||||
void File_WriteBE32(unsigned long value, FILE *stream);
|
||||
void File_WriteLE16(unsigned short value, FILE *stream);
|
||||
void File_WriteLE32(unsigned long value, FILE *stream);
|
Loading…
Add table
Reference in a new issue