summaryrefslogtreecommitdiff
path: root/plugins/adplug/libbinio/binfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/adplug/libbinio/binfile.cpp')
-rw-r--r--plugins/adplug/libbinio/binfile.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/plugins/adplug/libbinio/binfile.cpp b/plugins/adplug/libbinio/binfile.cpp
index 336f1b3b..a20315ac 100644
--- a/plugins/adplug/libbinio/binfile.cpp
+++ b/plugins/adplug/libbinio/binfile.cpp
@@ -22,6 +22,8 @@
#include "binfile.h"
+extern DB_functions_t *deadbeef;
+
/***** binfbase *****/
binfbase::binfbase()
@@ -37,7 +39,8 @@ binfbase::~binfbase()
void binfbase::close()
{
if(f != NULL) {
- if(fclose(f) == EOF) err |= Fatal; else f = NULL;
+ deadbeef->fclose(f);
+ f = NULL;
} else
err |= NotOpen;
}
@@ -49,9 +52,9 @@ void binfbase::seek(long pos, Offset offs)
if(f == NULL) { err |= NotOpen; return; }
switch(offs) {
- case Set: error = fseek(f, pos, SEEK_SET); break;
- case Add: error = fseek(f, pos, SEEK_CUR); break;
- case End: error = fseek(f, pos, SEEK_END); break;
+ case Set: error = deadbeef->fseek(f, pos, SEEK_SET); break;
+ case Add: error = deadbeef->fseek(f, pos, SEEK_CUR); break;
+ case End: error = deadbeef->fseek(f, pos, SEEK_END); break;
}
if(error == -1) err |= Fatal;
@@ -63,7 +66,7 @@ long binfbase::pos()
if(f == NULL) { err |= NotOpen; return 0; }
- pos = ftell(f);
+ pos = deadbeef->ftell(f);
if(pos == -1) {
err |= Fatal;
@@ -96,7 +99,7 @@ binifstream::~binifstream()
void binifstream::open(const char *filename, const Mode mode)
{
- f = fopen(filename, "rb");
+ f = deadbeef->fopen(filename);
if(f == NULL)
switch(errno) {
@@ -118,8 +121,9 @@ binifstream::Byte binifstream::getByte()
int read;
if(f != NULL) {
- read = fgetc(f);
- if(read == EOF) err |= Eof;
+ if (1 != deadbeef->fread (&read, 1, 1, f)) {
+ err |= Eof;
+ }
return (Byte)read;
} else {
err |= NotOpen;
@@ -151,6 +155,7 @@ binofstream::~binofstream()
void binofstream::open(const char *filename, const Mode mode)
{
+#if 0
const char *modestr = "wb";
// Check if append mode is desired
@@ -168,6 +173,7 @@ void binofstream::open(const char *filename, const Mode mode)
case ENOENT: err |= NotFound; break;
default: err |= NotOpen; break;
}
+#endif
}
#if BINIO_ENABLE_STRING
@@ -179,10 +185,12 @@ void binofstream::open(const std::string &filename, const Mode mode)
void binofstream::putByte(Byte b)
{
+#if 0
if(f == NULL) { err |= NotOpen; return; }
if(fputc(b, f) == EOF)
err |= Fatal;
+#endif
}
/***** binfstream *****/
@@ -220,11 +228,11 @@ void binfstream::open(const char *filename, const Mode mode)
if(mode & Append) // Create & append
modestr = "a+b";
- f = fopen(filename, modestr);
+ f = deadbeef->fopen(filename);
// NoCreate & append (emulated -- not possible with standard C fopen())
if(f != NULL && (mode & Append) && (mode & NoCreate))
- ferror = fseek(f, 0, SEEK_END);
+ ferror = deadbeef->fseek(f, 0, SEEK_END);
if(f == NULL || ferror == -1) {
switch(errno) {