Revert commit ID eb415081365ae7736bf6d0436d008d374c34a884
[platform/framework/native/appfw.git] / src / io / inc / FIo_SecureFile.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FIo_SecureFile.h
20  * @brief       This is the header file for the _SecureFile class.
21  *
22  * This header file contains the declarations of the _SecureFile class.
23  */
24
25 #ifndef _FIO_INTERNAL_SECURE_FILE_IMPL_H_
26 #define _FIO_INTERNAL_SECURE_FILE_IMPL_H_
27
28 #include <FBaseObject.h>
29
30 #include <FIo_FileImpl.h>
31 #include <FIo_IFileCore.h>
32
33 namespace Tizen { namespace Base
34 {
35 class String;
36 class ByteBuffer;
37 }}
38
39 namespace Tizen { namespace Io
40 {
41
42 class _SecureFile
43         : public Tizen::Base::Object
44         , public _IFileCore
45 {
46
47 public:
48         _SecureFile(bool read, bool write, bool truncate, bool append);
49
50         result Construct(const Tizen::Base::String& filePath, const char* pOpenMode, const Tizen::Base::ByteBuffer* pSecretKey);
51
52         virtual ~_SecureFile(void);
53
54         result Read(Tizen::Base::ByteBuffer& buffer);
55
56         int Read(void* buffer, int length);
57
58         result Read(Tizen::Base::String& buffer);
59
60         result Write(const Tizen::Base::ByteBuffer& buffer);
61
62         result Write(const void* buffer, int length);
63
64         result Write(const Tizen::Base::String& buffer);
65
66         result Flush(void);
67
68         int Tell(void) const;
69
70         result Seek(FileSeekPosition position, long offset);
71
72         result Truncate(int length);
73
74         Tizen::Base::String GetName(void);
75
76         virtual FILE* GetFilePointer(void)
77         {
78                 return __pNormalFile->GetFilePointer();
79         }
80
81 private:
82         _SecureFile(void);
83
84         _SecureFile(const _SecureFile& source);
85
86         _SecureFile& operator =(const _SecureFile& source);
87
88         Tizen::Base::String __filePath;
89         _NormalFile* __pNormalFile;
90         bool __constructed;
91         long __virtualFilePointer;
92         Tizen::Base::ByteBuffer* __pKey;
93
94 }; // _SecureFile
95
96 }} // Tizen::Io
97
98 #endif // _FIO_INTERNAL_SECURE_FILE_IMPL_H_
99