1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: io_RomFileStream.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision:$ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_IO_ROM_FILE_STREAM_H_ 17 #define NW_IO_ROM_FILE_STREAM_H_ 18 19 #include <nn/fs.h> 20 #include <nw/io/io_FileStream.h> 21 22 namespace nw { 23 namespace io { 24 25 class RomFileStream : public FileStream 26 { 27 public: 28 NW_UT_RUNTIME_TYPEINFO; 29 30 RomFileStream(); 31 RomFileStream( const char* path ); 32 // RomFileStream( const wchar_t* path ); 33 #ifdef NW_PLATFORM_CTRWIN 34 RomFileStream( const nn::fs::File* openedFile, bool closeEnable = true ); 35 #else 36 RomFileStream( nn::fs::FileReader* openedFileReader, bool closeEnable = true ); 37 #endif 38 virtual ~RomFileStream(); 39 40 bool Open( const char* path ); 41 // bool Open( const wchar_t* path ); 42 #ifdef NW_PLATFORM_CTRWIN 43 bool Open( const nn::fs::File* openedFile, bool closeEnable = true ); 44 #else 45 bool Open( nn::fs::FileReader* openedFileReader, bool closeEnable = true ); 46 #endif 47 virtual void Close(); 48 virtual s32 Read( void* buf, u32 length ); 49 50 virtual void Seek( s32 offset, u32 origin ); GetSize()51 virtual u32 GetSize() const { return m_FilePosition.GetFileSize(); } Tell()52 virtual u32 Tell() const { return m_FilePosition.Tell(); } 53 CanSeek()54 virtual bool CanSeek() const { return true; } CanCancel()55 virtual bool CanCancel() const { return false; } // TODO: CTR_SDK で非同期ロードサポートされたら true CanRead()56 virtual bool CanRead() const { return true; } CanWrite()57 virtual bool CanWrite() const { return false; } CanAsync()58 virtual bool CanAsync() const { return false; } // TODO: CTR_SDK で非同期ロードサポートされたら true 59 60 protected: 61 62 private: 63 void Initialize(); 64 65 FilePosition m_FilePosition; 66 67 #ifdef NW_PLATFORM_CTRWIN 68 nn::fs::File m_File; 69 /* TODO: オープン済みのファイルを nn::fs::FileReader で扱えるようになったら、 70 完全に nn::fs::FileReader を使う実装に置き換える */ 71 #else 72 nn::fs::FileReader m_FileReader; 73 nn::fs::FileReader* m_pOpenedFileReader; 74 #endif 75 bool m_IsAvailable; 76 bool m_CloseOnDestroyFlag; // true: デストラクト時にファイルをクローズする 77 bool m_CloseEnableFlag; // true: RomFileStream 内でファイルのクローズを許可 78 79 }; 80 81 82 } // namespace nw::io 83 } // namespace nw 84 85 86 #endif /* NW_IO_ROM_FILE_STREAM_H_ */ 87 88