/*---------------------------------------------------------------------------* Project: NintendoWare File: io_RomFileStream.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision:$ *---------------------------------------------------------------------------*/ #ifndef NW_IO_ROM_FILE_STREAM_H_ #define NW_IO_ROM_FILE_STREAM_H_ #include #include namespace nw { namespace io { class RomFileStream : public FileStream { public: NW_UT_RUNTIME_TYPEINFO; RomFileStream(); RomFileStream( const char* path ); // RomFileStream( const wchar_t* path ); #ifdef NW_PLATFORM_CTRWIN RomFileStream( const nn::fs::File* openedFile, bool closeEnable = true ); #else RomFileStream( nn::fs::FileReader* openedFileReader, bool closeEnable = true ); #endif virtual ~RomFileStream(); bool Open( const char* path ); // bool Open( const wchar_t* path ); #ifdef NW_PLATFORM_CTRWIN bool Open( const nn::fs::File* openedFile, bool closeEnable = true ); #else bool Open( nn::fs::FileReader* openedFileReader, bool closeEnable = true ); #endif virtual void Close(); virtual s32 Read( void* buf, u32 length ); virtual void Seek( s32 offset, u32 origin ); virtual u32 GetSize() const { return m_FilePosition.GetFileSize(); } virtual u32 Tell() const { return m_FilePosition.Tell(); } virtual bool CanSeek() const { return true; } virtual bool CanCancel() const { return false; } // TODO: CTR_SDK で非同期ロードサポートされたら true virtual bool CanRead() const { return true; } virtual bool CanWrite() const { return false; } virtual bool CanAsync() const { return false; } // TODO: CTR_SDK で非同期ロードサポートされたら true protected: private: void Initialize(); FilePosition m_FilePosition; #ifdef NW_PLATFORM_CTRWIN nn::fs::File m_File; /* TODO: オープン済みのファイルを nn::fs::FileReader で扱えるようになったら、 完全に nn::fs::FileReader を使う実装に置き換える */ #else nn::fs::FileReader m_FileReader; nn::fs::FileReader* m_pOpenedFileReader; #endif bool m_IsAvailable; bool m_CloseOnDestroyFlag; // true: デストラクト時にファイルをクローズする bool m_CloseEnableFlag; // true: RomFileStream 内でファイルのクローズを許可 }; } // namespace nw::io } // namespace nw #endif /* NW_IO_ROM_FILE_STREAM_H_ */