1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_HioSoundArchive.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_SND_HIO_SOUND_ARCHIVE_H_ 17 #define NW_SND_HIO_SOUND_ARCHIVE_H_ 18 19 #include <nn/hio.h> 20 #include <nw/io/io_HioFileStream.h> 21 #include <nw/snd/snd_SoundArchive.h> 22 #include <nw/snd/snd_SoundArchiveFileReader.h> 23 24 namespace nw { 25 namespace snd { 26 27 //! @details :private 28 class HioSoundArchive : public SoundArchive 29 { 30 public: 31 class HioFileStream; 32 33 public: 34 HioSoundArchive(); 35 virtual ~HioSoundArchive(); 36 37 bool Open( const char* filePath ); 38 void Close(); 39 GetHeaderSize()40 size_t GetHeaderSize() const { return m_ArchiveReader.GetInfoBlockSize(); } 41 bool LoadHeader( void* buffer, size_t size ); 42 GetLabelStringDataSize()43 size_t GetLabelStringDataSize() const { return m_ArchiveReader.GetStringBlockSize(); } 44 bool LoadLabelStringData( void* buffer, size_t size ); 45 46 virtual size_t detail_GetRequiredStreamBufferSize() const; detail_GetFileAddress(FileId)47 virtual const void* detail_GetFileAddress( FileId ) const 48 { 49 return NULL; // NOTE: MemorySoundArchive なら非 NULL を返しうる 50 } 51 52 void SetRootDirectory( const char* rootDirectory ); 53 54 protected: 55 virtual io::FileStream* OpenStream( 56 void* buffer, 57 int size, 58 u32 begin, 59 u32 length ); 60 virtual io::FileStream* OpenExtStream( 61 void* buffer, 62 int size, 63 const char* extFilePathFilePath, 64 u32 begin, 65 u32 length ) const; 66 67 private: 68 bool LoadFileHeader(); 69 internal::SoundArchiveFileReader m_ArchiveReader; 70 nn::hio::HostFile m_HostFile; // PcSDK 版は未実装 71 bool m_IsOpened; 72 char m_RootDirectory[ FILE_PATH_MAX ]; 73 }; 74 75 class HioSoundArchive::HioFileStream : public io::HioFileStream 76 { 77 public: 78 HioFileStream( const char* path, u32 uffset, u32 size ); 79 HioFileStream( nn::hio::HostFile* openedFile, u32 offset, u32 size ); 80 81 virtual s32 Read( void* buf, u32 length ); 82 virtual void Seek( s32 offset, u32 origin ); Tell()83 virtual u32 Tell() const { return io::HioFileStream::Tell() - m_Offset; } GetSize()84 virtual u32 GetSize() const { return m_Size; } 85 private: 86 s32 m_Offset; 87 u32 m_Size; 88 }; 89 90 } // namespace nw::snd 91 } // namespace nw 92 93 #endif /* NW_SND_HIO_SOUND_ARCHIVE_H_ */ 94 95