2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FIo_DirEntryImpl.cpp
19 * @brief This is the implementation file for _DirEntryImpl class.
22 #include <unique_ptr.h>
23 #include <FBaseString.h>
24 #include <FBaseDateTime.h>
25 #include <FIoDirEntry.h>
26 #include <FBaseSysLog.h>
28 #include <FBase_NativeError.h>
29 #include <FIo_DirEntryImpl.h>
31 using namespace Tizen::Base;
33 namespace Tizen { namespace Io
36 _DirEntryImpl::_DirEntryImpl(void)
44 _DirEntryImpl::~_DirEntryImpl(void)
49 _DirEntryImpl::GetInstance(DirEntry* pDirEntry)
53 return pDirEntry->__pDirEntryImpl;
60 _DirEntryImpl::GetInstance(const DirEntry* pDirEntry)
64 return pDirEntry->__pDirEntryImpl;
70 _DirEntryImpl::_DirEntryImpl(const _DirEntryImpl& dirEntryImpl)
75 __dateTime = dirEntryImpl.__dateTime;
76 __fileSize = dirEntryImpl.__fileSize;
77 __name = dirEntryImpl.__name;
78 __directory = dirEntryImpl.__directory;
79 __hidden = dirEntryImpl.__hidden;
80 __readOnly = dirEntryImpl.__readOnly;
84 _DirEntryImpl::operator =(const _DirEntryImpl& dirEntryImpl)
86 if (&dirEntryImpl != this)
88 __dateTime = dirEntryImpl.__dateTime;
89 __fileSize = dirEntryImpl.__fileSize;
90 __name = dirEntryImpl.__name;
91 __directory = dirEntryImpl.__directory;
92 __hidden = dirEntryImpl.__hidden;
93 __readOnly = dirEntryImpl.__readOnly;
100 _DirEntryImpl::Equals(const Object& object) const
102 const _DirEntryImpl* pOther = dynamic_cast< const _DirEntryImpl* >(&object);
108 if (__dateTime == pOther->__dateTime && __fileSize == pOther->__fileSize &&
109 __name == pOther->__name && __directory == pOther->__directory &&
110 __hidden == pOther->__hidden && __readOnly == pOther->__readOnly)
119 _DirEntryImpl::GetHashCode(void) const
123 hashCode.Append(__dateTime.ToString());
124 hashCode.Append(static_cast< long >(__fileSize));
125 hashCode.Append(__name);
126 hashCode.Append(static_cast< int >(__directory));
127 hashCode.Append(static_cast< int >(__hidden));
128 hashCode.Append(static_cast< int >(__readOnly));
130 return hashCode.GetHashCode();
133 const Tizen::Base::String
134 _DirEntryImpl::GetName(void) const
136 SetLastResult(E_SUCCESS);
141 _DirEntryImpl::GetFileSize(void) const
143 SetLastResult(E_SUCCESS);
144 return static_cast< unsigned long >(__fileSize);
148 _DirEntryImpl::IsDirectory(void) const
150 SetLastResult(E_SUCCESS);
155 _DirEntryImpl::IsHidden(void) const
157 SetLastResult(E_SUCCESS);
162 _DirEntryImpl::IsReadOnly(void) const
164 SetLastResult(E_SUCCESS);
168 Tizen::Base::DateTime
169 _DirEntryImpl::GetDateTime(void) const
171 SetLastResult(E_SUCCESS);
176 _DirEntryImpl::Set(DateTime dateTime, off64_t fileSize, String name,
177 bool dir, bool readOnly, bool hidden)
179 __dateTime = dateTime;
180 __fileSize = fileSize;
183 __readOnly = readOnly;
188 _DirEntryImpl::CreateDirEntryInstanceN(void)
190 std::unique_ptr<DirEntry> pDirEntry(new (std::nothrow) DirEntry());
191 SysTryReturn(NID_IO, pDirEntry != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
192 return pDirEntry.release();