PageRenderTime 52ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLVFILE_H
  27. #define LL_LLVFILE_H
  28. #include "lluuid.h"
  29. #include "llassettype.h"
  30. #include "llvfs.h"
  31. #include "llvfsthread.h"
  32. class LLVFile
  33. {
  34. public:
  35. LLVFile(LLVFS *vfs, const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLVFile::READ);
  36. ~LLVFile();
  37. BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */
  38. static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0);
  39. void setReadPriority(const F32 priority);
  40. BOOL isReadComplete();
  41. S32 getLastBytesRead();
  42. BOOL eof();
  43. BOOL write(const U8 *buffer, S32 bytes);
  44. static BOOL writeFile(const U8 *buffer, S32 bytes, LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type);
  45. BOOL seek(S32 offset, S32 origin = -1);
  46. S32 tell() const;
  47. S32 getSize();
  48. S32 getMaxSize();
  49. BOOL setMaxSize(S32 size);
  50. BOOL rename(const LLUUID &new_id, const LLAssetType::EType new_type);
  51. BOOL remove();
  52. bool isLocked(EVFSLock lock);
  53. void waitForLock(EVFSLock lock);
  54. static void initClass(LLVFSThread* vfsthread = NULL);
  55. static void cleanupClass();
  56. static LLVFSThread* getVFSThread() { return sVFSThread; }
  57. protected:
  58. static LLVFSThread* sVFSThread;
  59. static BOOL sAllocdVFSThread;
  60. U32 threadPri() { return LLVFSThread::PRIORITY_NORMAL + llmin((U32)mPriority,(U32)0xfff); }
  61. public:
  62. static const S32 READ;
  63. static const S32 WRITE;
  64. static const S32 READ_WRITE;
  65. static const S32 APPEND;
  66. protected:
  67. LLAssetType::EType mFileType;
  68. LLUUID mFileID;
  69. S32 mPosition;
  70. S32 mMode;
  71. LLVFS *mVFS;
  72. F32 mPriority;
  73. S32 mBytesRead;
  74. LLVFSThread::handle_t mHandle;
  75. };
  76. #endif