PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: FileAndroid.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_FILE_ANDROID_H__ 00024 #define __PLCORE_FILE_ANDROID_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/File/FileImpl.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Forward declarations ] 00036 //[-------------------------------------------------------] 00037 struct AAsset; 00038 typedef struct AAsset AAsset; 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Namespace ] 00043 //[-------------------------------------------------------] 00044 namespace PLCore { 00045 00046 00047 //[-------------------------------------------------------] 00048 //[ Classes ] 00049 //[-------------------------------------------------------] 00050 /** 00051 * @brief 00052 * Android implementation of FileImpl 00053 * 00054 * @note 00055 * - Implementation of the state design pattern, this class is a concrete state of the 'FileImpl'-state of the 'FileObject'-context 00056 * - This implementation is using the Android asset manager received from "SystemAndroid::GetAssetManager()" 00057 */ 00058 class FileAndroid : public FileImpl { 00059 00060 00061 //[-------------------------------------------------------] 00062 //[ Friends ] 00063 //[-------------------------------------------------------] 00064 friend class FileObject; 00065 00066 00067 //[-------------------------------------------------------] 00068 //[ Private functions ] 00069 //[-------------------------------------------------------] 00070 private: 00071 /** 00072 * @brief 00073 * Constructor 00074 * 00075 * @param[in] cUrl 00076 * URL of the file or directory 00077 * @param[in] pAccess 00078 * Additional file access information (can be a null pointer) 00079 */ 00080 FileAndroid(const Url &cUrl, const FileAccess *pAccess); 00081 00082 /** 00083 * @brief 00084 * Destructor 00085 */ 00086 virtual ~FileAndroid(); 00087 00088 00089 //[-------------------------------------------------------] 00090 //[ Private virtual FileImpl functions ] 00091 //[-------------------------------------------------------] 00092 private: 00093 virtual bool Exists() const override; 00094 virtual bool IsFile() const override; 00095 virtual bool IsDirectory() const override; 00096 virtual bool CopyTo(const String &sDest, bool bOverwrite) const override; 00097 virtual bool MoveTo(const String &sDest) override; 00098 virtual bool Rename(const String &sName) override; 00099 virtual bool CreateNewFile(bool bAlways) override; 00100 virtual bool CreateNewDirectory() override; 00101 virtual bool Delete() override; 00102 virtual bool DeleteDirectory() override; 00103 virtual void Close() override; 00104 virtual bool Open(uint32 nAccess, String::EFormat nStringFormat = String::ASCII) override; 00105 virtual bool IsOpen() const override; 00106 virtual bool IsReadable() const override; 00107 virtual bool IsWritable() const override; 00108 virtual String::EFormat GetStringFormat() const override; 00109 virtual bool IsEof() const override; 00110 virtual int GetC() override; 00111 virtual bool PutC(int nChar) override; 00112 virtual String GetS() override; 00113 virtual int PutS(const String &sString) override; 00114 virtual uint32 Read(void *pBuffer, uint32 nSize, uint32 nCount) override; 00115 virtual uint32 Write(const void *pBuffer, uint32 nSize, uint32 nCount) override; 00116 virtual bool Flush() override; 00117 virtual bool Seek(int32 nOffset, uint32 nLocation) override; 00118 virtual int32 Tell() const override; 00119 virtual uint32 GetSize() const override; 00120 virtual FileSearchImpl *CreateSearch() override; 00121 00122 00123 //[-------------------------------------------------------] 00124 //[ Private data ] 00125 //[-------------------------------------------------------] 00126 private: 00127 String m_sFilename; /**< File name (in Linux notation) */ 00128 uint32 m_nAccess; /**< File access modes (see EAccess) */ 00129 AAsset *m_pAAsset; /**< Pointer to the Android asset, can be a null pointer */ 00130 00131 00132 }; 00133 00134 00135 //[-------------------------------------------------------] 00136 //[ Namespace ] 00137 //[-------------------------------------------------------] 00138 } // PLCore 00139 00140 00141 #endif // __PLCORE_FILE_ANDROID_H__
|