PhysFSFile.h

Go to the documentation of this file.
00001 #ifndef __LDK_PHYSFSFILE_H__
00002 #define __LDK_PHYSFSFILE_H__
00003 
00005 //   Copyright (C) 2003-2006 Lorien Dunn.
00006 //
00007 //   Contact: loriendunn AT users DOT sourceforge DOT net
00008 //
00009 //   This software is provided 'as-is', without any express or implied warranty.
00010 //   In no event will the authors be held liable for any damages arising from
00011 //   the use of this software.
00012 //
00013 //   Permission is granted to anyone to use this software for any purpose,
00014 //   including commercial applications, and to alter it and redistribute it
00015 //   freely, subject to the following restrictions:
00016 //
00017 //   1. The origin of this software must not be misrepresented; you must not
00018 //   claim that you wrote the original software. If you use this software in a
00019 //   product, an acknowledgment in the product documentation would be
00020 //   appreciated but is not required.
00021 //
00022 //   2. Altered source versions must be plainly marked as such, and must not be
00023 //   misrepresented as being the original software.
00024 //
00025 //   3. This notice may not be removed or altered from any source distribution.
00026 //
00028 
00033 
00034 #include "LDK/VFile.h"
00035 #include <physfs.h>
00036 
00037 namespace LDK
00038 {
00065 class LDK_API PhysFSFile : public VFile
00066 {
00067 protected:
00068 
00069     PHYSFS_file*  mFile;
00070     int mUnget;
00071     int64 mPos;
00072 
00073     void resetPos();
00074 
00075 public:
00076 
00077     PhysFSFile(PHYSFS_file* file=NULL);
00078     virtual ~PhysFSFile() throw();
00079 
00080     virtual void openRead(const char* fileName, bool text=false);
00081     virtual void openWrite(const char* fileName, bool text=false);
00082     virtual void openAppend(const char* fileName, bool text=false);
00083     virtual int64 length();
00084     virtual void close();
00085 
00086     virtual bool eof();
00087     virtual int64 tell();
00088     virtual int64 seek(int64 offset, int whence);
00089     virtual void flush();
00090 
00091     inline PHYSFS_file* handle() { return mFile; }
00092 
00093 
00094     //note arg order is different from PHYSFS_read!
00095     virtual int64 read(void *buffer, uint32 objCount, uint32 objSize=1);
00096     virtual int32 getc();
00097     //warning: dirty hack: does not push back the char into the buffer
00098     virtual int32 ungetc(char c);
00099     //like fgets
00100     virtual const char* gets(char* buffer, uint32 size);
00101 
00102     //note arg order is different from PHYSFS_write!
00103     virtual int64 write(const void *buffer, uint32 objCount, uint32 objSize=1);
00104     virtual int32 putc(char c);
00105     virtual int32 puts(const char* str); //like fputs i.e. no \n appended
00106     virtual int32 printf(const char* format, ...);
00107     virtual int32 vprintf(const char *format, va_list ap);
00108 };
00109 
00110 }//namespace LDK
00111 
00112 #endif //__LDK_PHYSFSFILE_H__

Generated on Fri Aug 17 18:32:26 2007 for LDK by  doxygen 1.5.1