Add exception check
[platform/framework/native/appfw.git] / src / io / FIoFileAttributes.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FIoFileAttributes.cpp
19  * @brief       This is the implementation file for FIoFileAttributes class.
20  */
21
22 #include <new>
23
24 #include <FIoFileAttributes.h>
25 #include <FBaseSysLog.h>
26
27 #include <FBase_NativeError.h>
28 #include <FIo_FileAttributesImpl.h>
29
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Io
33 {
34
35 FileAttributes::FileAttributes(void)
36         : __pFileAttributesImpl(null)
37 {
38         __pFileAttributesImpl = new (std::nothrow) _FileAttributesImpl;
39         SysTryReturnVoidResult(NID_IO, __pFileAttributesImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
40 }
41
42 FileAttributes::~FileAttributes(void)
43 {
44         delete __pFileAttributesImpl;
45 }
46
47 FileAttributes::FileAttributes(const FileAttributes& fileAttributes)
48         : __pFileAttributesImpl(null)
49 {
50         __pFileAttributesImpl = new (std::nothrow) _FileAttributesImpl(*fileAttributes.__pFileAttributesImpl);
51         SysTryReturnVoidResult(NID_IO, __pFileAttributesImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
52 }
53
54 FileAttributes&
55 FileAttributes::operator =(const FileAttributes& fileAttributes)
56 {
57         if (&fileAttributes != this)
58         {
59                 delete __pFileAttributesImpl;
60
61                 __pFileAttributesImpl = new (std::nothrow) _FileAttributesImpl(*fileAttributes.__pFileAttributesImpl);
62                 SysLogException(NID_IO, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
63
64         }
65
66         return *this;
67 }
68
69 bool
70 FileAttributes::Equals(const Object& object) const
71 {
72         const FileAttributes* pOther = dynamic_cast< const FileAttributes* >(&object);
73         if (pOther == null)
74         {
75                 return false;
76         }
77
78         return __pFileAttributesImpl->Equals(*(pOther->__pFileAttributesImpl));
79 }
80
81 int
82 FileAttributes::GetHashCode(void) const
83 {
84         return __pFileAttributesImpl->GetHashCode();
85 }
86
87 long long
88 FileAttributes::GetFileSize(void) const
89 {
90         return __pFileAttributesImpl->GetFileSize();
91 }
92
93 DateTime
94 FileAttributes::GetDateTime(void) const
95 {
96         return __pFileAttributesImpl->GetDateTime();
97 }
98
99 DateTime
100 FileAttributes::GetLastModifiedTime(void) const
101 {
102         return __pFileAttributesImpl->GetLastModifiedTime();
103 }
104
105 bool
106 FileAttributes::IsDirectory(void) const
107 {
108         return __pFileAttributesImpl->IsDirectory();
109 }
110
111 bool
112 FileAttributes::IsHidden(void) const
113 {
114         return __pFileAttributesImpl->IsHidden();
115 }
116
117 bool
118 FileAttributes::IsReadOnly(void) const
119 {
120         return __pFileAttributesImpl->IsReadOnly();
121 }
122
123 }} // Tizen::Io
124