PageRenderTime 25ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llvfs/llvfile.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 90 lines | 51 code | 14 blank | 25 comment | 0 complexity | 34ab339431c3e91015a60545eb764c8d MD5 | raw file
 1/** 
 2 * @file llvfile.h
 3 * @brief Definition of virtual file
 4 *
 5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLVFILE_H
28#define LL_LLVFILE_H
29
30#include "lluuid.h"
31#include "llassettype.h"
32#include "llvfs.h"
33#include "llvfsthread.h"
34
35class LLVFile
36{
37public:
38	LLVFile(LLVFS *vfs, const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLVFile::READ);
39	~LLVFile();
40
41	BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f);	/* Flawfinder: ignore */ 
42	static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0);
43	void setReadPriority(const F32 priority);
44	BOOL isReadComplete();
45	S32  getLastBytesRead();
46	BOOL eof();
47
48	BOOL write(const U8 *buffer, S32 bytes);
49	static BOOL writeFile(const U8 *buffer, S32 bytes, LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type);
50	BOOL seek(S32 offset, S32 origin = -1);
51	S32  tell() const;
52
53	S32 getSize();
54	S32 getMaxSize();
55	BOOL setMaxSize(S32 size);
56	BOOL rename(const LLUUID &new_id, const LLAssetType::EType new_type);
57	BOOL remove();
58
59	bool isLocked(EVFSLock lock);
60	void waitForLock(EVFSLock lock);
61	
62	static void initClass(LLVFSThread* vfsthread = NULL);
63	static void cleanupClass();
64	static LLVFSThread* getVFSThread() { return sVFSThread; }
65
66protected:
67	static LLVFSThread* sVFSThread;
68	static BOOL sAllocdVFSThread;
69	U32 threadPri() { return LLVFSThread::PRIORITY_NORMAL + llmin((U32)mPriority,(U32)0xfff); }
70	
71public:
72	static const S32 READ;
73	static const S32 WRITE;
74	static const S32 READ_WRITE;
75	static const S32 APPEND;
76	
77protected:
78	LLAssetType::EType mFileType;
79
80	LLUUID	mFileID;
81	S32		mPosition;
82	S32		mMode;
83	LLVFS	*mVFS;
84	F32		mPriority;
85
86	S32		mBytesRead;
87	LLVFSThread::handle_t mHandle;
88};
89
90#endif