1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     io_HioFileStream.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_HIO_FILE_STREAM_H_
17 #define NW_IO_HIO_FILE_STREAM_H_
18 
19 #include <nn/hio.h>
20 #include <nw/io/io_FileStream.h>
21 
22 namespace nw {
23 namespace io {
24 
25 class HioFileStream : public FileStream
26 {
27 public:
28     NW_UT_RUNTIME_TYPEINFO;
29 
30     HioFileStream();
31     HioFileStream( const char* path, bit32 accessMode, nn::hio::HostFile::OpenDisp );
32     // HioFileStream( const wchar_t* path );
33 #ifdef NW_PLATFORM_CTRWIN
34     HioFileStream( ... );
35 #else
36     HioFileStream( nn::hio::HostFile*, bit32 accessMode, bool closeEnable = true );
37 #endif
38     virtual ~HioFileStream();
39 
40     bool Open( const char* path, bit32 accessMode, nn::hio::HostFile::OpenDisp );
41     // bool Open( const wchar_t* path );
42 #ifdef NW_PLATFORM_CTRWIN
43     bool Open( ... );
44 #else
45     bool Open( nn::hio::HostFile*, bit32 accessMode, bool closeEnable = true );
46 #endif
47     virtual void Close();
48     virtual s32 Read( void* buf, u32 length );
49     virtual s32 Write( const void* buf, u32 length );
50 
51     virtual void Seek( s32 offset, u32 origin );
GetSize()52     virtual u32 GetSize() const { return m_FilePosition.GetFileSize(); }
Tell()53     virtual u32 Tell() const { return m_FilePosition.Tell(); }
54 
CanSeek()55     virtual bool CanSeek()   const { return true; }
CanCancel()56     virtual bool CanCancel() const { return false; }
CanRead()57     virtual bool CanRead()   const { return m_CanRead; }
CanWrite()58     virtual bool CanWrite()  const { return m_CanWrite; }
CanAsync()59     virtual bool CanAsync()  const { return false; }
60 
61 protected:
62 
63 private:
64     void Initialize();
65 
66     FilePosition m_FilePosition;
67 
68 #ifdef NW_PLATFORM_CTRWIN
69     // TODO:
70 #else
71     nn::hio::HostFile m_File;
72     nn::hio::HostFile* m_pOpenedFile;
73 
74 #endif
75     bool m_CanRead;
76     bool m_CanWrite;
77     bool m_IsAvailable;
78     bool m_CloseOnDestroyFlag;  // true: デストラクト時にファイルをクローズする
79     bool m_CloseEnableFlag;     // true: HioFileStream 内でファイルのクローズを許可
80 
81 };
82 
83 
84 } // namespace nw::io
85 } // namespace nw
86 
87 
88 #endif /* NW_IO_HIO_FILE_STREAM_H_ */
89 
90