00001 #include <stdio.h>
00002 #include "file.hpp"
00003
00004
00006
00007 ADR_FILE ADR_CALL DefaultFileOpen(void* , const char* filename)
00008 {
00009 return (ADR_FILE)fopen(filename, "rb");
00010 }
00011
00013
00014 void ADR_CALL DefaultFileClose(ADR_FILE file)
00015 {
00016 fclose((FILE*)file);
00017 }
00018
00020
00021 int ADR_CALL DefaultFileRead(ADR_FILE file, void* buffer, int size)
00022 {
00023 return fread(buffer, 1, size, (FILE*)file);
00024 }
00025
00027
00028 int ADR_CALL DefaultFileSeek(
00029 ADR_FILE file,
00030 int destination,
00031 ADR_SEEK_TYPE origin)
00032 {
00033 int o;
00034 switch (origin) {
00035 case ADR_BEGIN: o = SEEK_SET; break;
00036 case ADR_CURRENT: o = SEEK_CUR; break;
00037 case ADR_END: o = SEEK_END; break;
00038 default: return -1;
00039 }
00040
00041 return (0 == fseek((FILE*)file, destination, o));
00042 }
00043
00045
00046 int ADR_CALL DefaultFileTell(ADR_FILE file)
00047 {
00048 return ftell((FILE*)file);
00049 }
00050