1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     io_HioFileStream.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_IO_HIO_FILE_STREAM_H_
19 #define NW_IO_HIO_FILE_STREAM_H_
20 
21 #include <nn/hio.h>
22 #include <nw/io/io_FileStream.h>
23 
24 namespace nw {
25 namespace io {
26 
27 class HioFileStream : public FileStream
28 {
29 public:
30     NW_UT_RUNTIME_TYPEINFO;
31 
32     HioFileStream();
33     HioFileStream( const char* path, bit32 accessMode, nn::hio::HostFile::OpenDisp );
34     // HioFileStream( const wchar_t* path );
35 #ifdef NW_PLATFORM_CTRWIN
36     HioFileStream( ... );
37 #else
38     HioFileStream( nn::hio::HostFile*, bit32 accessMode, bool closeEnable = true );
39 #endif
40     virtual ~HioFileStream();
41 
42     bool Open( const char* path, bit32 accessMode, nn::hio::HostFile::OpenDisp );
43     // bool Open( const wchar_t* path );
44 #ifdef NW_PLATFORM_CTRWIN
45     bool Open( ... );
46 #else
47     bool Open( nn::hio::HostFile*, bit32 accessMode, bool closeEnable = true );
48 #endif
49     virtual void Close();
50     virtual s32 Read( void* buf, u32 length );
51     virtual s32 Write( const void* buf, u32 length );
52 
53     virtual void Seek( s32 offset, u32 origin );
GetSize()54     virtual u32 GetSize() const { return m_FilePosition.GetFileSize(); }
Tell()55     virtual u32 Tell() const { return m_FilePosition.Tell(); }
56 
CanSeek()57     virtual bool CanSeek()   const { return true; }
CanCancel()58     virtual bool CanCancel() const { return false; }
CanRead()59     virtual bool CanRead()   const { return m_CanRead; }
CanWrite()60     virtual bool CanWrite()  const { return m_CanWrite; }
CanAsync()61     virtual bool CanAsync()  const { return false; }
62 
63 protected:
64 
65 private:
66     void Initialize();
67 
68     FilePosition m_FilePosition;
69 
70 #ifdef NW_PLATFORM_CTRWIN
71     // TODO:
72 #else
73     nn::hio::HostFile m_File;
74     nn::hio::HostFile* m_pOpenedFile;
75 
76 #endif
77     bool m_CanRead;
78     bool m_CanWrite;
79     bool m_IsAvailable;
80     bool m_CloseOnDestroyFlag;  // true: デストラクト時にファイルをクローズする
81     bool m_CloseEnableFlag;     // true: HioFileStream 内でファイルのクローズを許可
82 
83 };
84 
85 
86 } // namespace nw::io
87 } // namespace nw
88 
89 
90 #endif /* NW_IO_HIO_FILE_STREAM_H_ */
91 
92