From 251661d2692c0f7d077fa1f74678d6baa36045eb Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 16 Jun 2004 04:25:03 +0000 Subject: [PATCH] remove OpenRWops --- stepmania/src/SDL_utils.cpp | 99 ------------------------------------- stepmania/src/SDL_utils.h | 4 -- 2 files changed, 103 deletions(-) diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index a0de41cd4a..966d58c760 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -95,105 +95,6 @@ uint8_t mySDL_EventState( uint8_t type, int state ) } - -int RWRageFile_Seek( struct SDL_RWops *context, int offset, int whence ) -{ - RageFile *f = (RageFile *) context->hidden.unknown.data1; - return f->Seek( (int) offset, whence ); -} - -int RWRageFile_Read( struct SDL_RWops *context, void *ptr, int size, int nmemb ) -{ - RageFile *f = (RageFile *) context->hidden.unknown.data1; - return f->Read( ptr, size, nmemb ); -} - -int RWRageFile_Write( struct SDL_RWops *context, const void *ptr, int size, int nmemb ) -{ - RageFile *f = (RageFile *) context->hidden.unknown.data1; - return f->Write( ptr, size, nmemb ); -} - -/* Close and free an allocated SDL_FSops structure */ -int RWRageFile_Close(struct SDL_RWops *context) -{ - return 0; -} - -void OpenRWops( SDL_RWops *rw, RageFile *f ) -{ - rw->hidden.unknown.data1 = f; - rw->seek = RWRageFile_Seek; - rw->read = RWRageFile_Read; - rw->write = RWRageFile_Write; - rw->close = RWRageFile_Close; -} - -struct RWString -{ - CString *buf; - int fp; - RWString( CString *b ): buf(b), fp(0) { } -}; - -int RWString_Seek( struct SDL_RWops *context, int offset, int whence ) -{ - RWString *f = (RWString *) context->hidden.unknown.data1; - - switch(whence) - { - case SEEK_CUR: offset += f->fp; break; - case SEEK_END: offset += f->buf->size(); break; - } - f->fp = min( offset, (int) f->buf->size() ); - return f->fp; -} - -int RWString_Read( struct SDL_RWops *context, void *ptr, int size, int nmemb ) -{ - RWString *f = (RWString *) context->hidden.unknown.data1; - CString &buf = *f->buf; - - size *= nmemb; - size = min( size, (int) buf.size() - f->fp ); - memcpy( ptr, buf.data()+f->fp, size ); - - f->fp += size; - return size; -} - -int RWString_Write( struct SDL_RWops *context, const void *ptr, int size, int nmemb ) -{ - RWString *f = (RWString *) context->hidden.unknown.data1; - CString &buf = *f->buf; - - size *= nmemb; - const int ahead = buf.size() - f->fp; - const int overwrite = min( size, ahead ); - buf.replace( buf.begin() + f->fp, buf.begin() + f->fp + overwrite, - (const char*)ptr, size ); - - f->fp += size; - return size; -} - -/* Close and free an allocated SDL_FSops structure */ -int RWString_Close(struct SDL_RWops *context) -{ - RWString *f = (RWString *) context->hidden.unknown.data1; - delete f; - return 0; -} - -void OpenRWops( SDL_RWops *rw, CString *sBuf ) -{ - rw->hidden.unknown.data1 = new RWString( sBuf ); - rw->seek = RWString_Seek; - rw->read = RWString_Read; - rw->write = RWString_Write; - rw->close = RWString_Close; -} - /* SDL sometimes fails to set an error, in which case we get the null string. We * sometimes use that as a sentinel return value. This function returns "(none)" * if no error is set. */ diff --git a/stepmania/src/SDL_utils.h b/stepmania/src/SDL_utils.h index 301170990d..ab25274a1b 100644 --- a/stepmania/src/SDL_utils.h +++ b/stepmania/src/SDL_utils.h @@ -21,10 +21,6 @@ uint8_t mySDL_EventState(uint8_t type, int state); void mySDL_GetAllEvents(vector &events); void mySDL_PushEvents(vector &events); -class RageFile; -void OpenRWops( SDL_RWops *rw, RageFile *f ); -void OpenRWops( SDL_RWops *rw, CString *sBuf ); - CString mySDL_GetError(); void mySDL_WM_SetIcon( CString sIconFile );