00001 /* 00002 * File object handler header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_INPUTOUTPUT_FILE_RAM_H__ 00009 #define __SP_INPUTOUTPUT_FILE_RAM_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 #include "Base/spInputOutputFile.hpp" 00014 #include "Base/spDimensionUniversalBuffer.hpp" 00015 00016 00017 namespace sp 00018 { 00019 namespace io 00020 { 00021 00022 00023 class SP_EXPORT FileVirtual : public File 00024 { 00025 00026 public: 00027 00028 FileVirtual(); 00029 FileVirtual(const io::stringc &Filename); 00030 ~FileVirtual(); 00031 00032 /* Functions */ 00033 00034 bool open(const io::stringc &Filename, const EFilePermission Permission = FILE_READWRITE); 00035 void close(); 00036 00037 s32 writeBuffer(const void* Buffer, u32 Size, u32 Count = 1); 00038 s32 readBuffer(void* Buffer, u32 Size, u32 Count = 1) const; 00039 00040 void setSeek(s32 Pos, const EFileSeekTypes PosType = FILEPOS_BEGIN); 00041 s32 getSeek() const; 00042 00043 bool isEOF() const; 00044 00045 u32 getSize() const; 00046 void* getHandle(); 00047 00048 bool opened() const; 00049 00050 /* Inline functions */ 00051 00052 inline const dim::UniversalBuffer& getBuffer() const 00053 { 00054 return Buffer_; 00055 } 00056 inline dim::UniversalBuffer& getBuffer() 00057 { 00058 return Buffer_; 00059 } 00060 00061 private: 00062 00063 /* Members */ 00064 00065 dim::UniversalBuffer Buffer_; 00066 mutable s32 Pos_; 00067 00068 bool isOpened_; 00069 bool hasWriteAccess_, hasReadAccess_; 00070 00071 }; 00072 00073 00074 } // /namespace io 00075 00076 } // /namespace sp 00077 00078 00079 #endif 00080 00081 00082 00083 // ================================================================================