00001
00032 #ifndef LL_LLVFILE_H
00033 #define LL_LLVFILE_H
00034
00035 #include "lluuid.h"
00036 #include "llassettype.h"
00037 #include "llvfs.h"
00038 #include "llvfsthread.h"
00039
00040 class LLVFile
00041 {
00042 public:
00043 LLVFile(LLVFS *vfs, const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLVFile::READ);
00044 ~LLVFile();
00045
00046 BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f);
00047 static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0);
00048 void setReadPriority(const F32 priority);
00049 BOOL isReadComplete();
00050 S32 getLastBytesRead();
00051 BOOL eof();
00052
00053 BOOL write(const U8 *buffer, S32 bytes);
00054 static BOOL writeFile(const U8 *buffer, S32 bytes, LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type);
00055 BOOL seek(S32 offset, S32 origin = -1);
00056 S32 tell() const;
00057
00058 S32 getSize();
00059 S32 getMaxSize();
00060 BOOL setMaxSize(S32 size);
00061 BOOL rename(const LLUUID &new_id, const LLAssetType::EType new_type);
00062 BOOL remove();
00063
00064 bool isLocked(EVFSLock lock);
00065 void waitForLock(EVFSLock lock);
00066
00067 static void initClass(LLVFSThread* vfsthread = NULL);
00068 static void cleanupClass();
00069 static LLVFSThread* getVFSThread() { return sVFSThread; }
00070
00071 protected:
00072 static LLVFSThread* sVFSThread;
00073 static BOOL sAllocdVFSThread;
00074 U32 threadPri() { return LLVFSThread::PRIORITY_NORMAL + llmin((U32)mPriority,(U32)0xfff); }
00075
00076 public:
00077 static const S32 READ;
00078 static const S32 WRITE;
00079 static const S32 READ_WRITE;
00080 static const S32 APPEND;
00081
00082 static BOOL ALLOW_ASYNC;
00083
00084 protected:
00085 LLAssetType::EType mFileType;
00086
00087 LLUUID mFileID;
00088 S32 mPosition;
00089 S32 mMode;
00090 LLVFS *mVFS;
00091 F32 mPriority;
00092 BOOL mOnReadQueue;
00093
00094 S32 mBytesRead;
00095 LLVFSThread::handle_t mHandle;
00096 };
00097
00098 #endif