2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FIo_DirEntryImpl.cpp
20 * @brief This is the implementation file for _DirEntryImpl class.
23 #include <unique_ptr.h>
24 #include <FBaseString.h>
25 #include <FBaseDateTime.h>
26 #include <FIoDirEntry.h>
27 #include <FBaseSysLog.h>
29 #include <FBase_NativeError.h>
30 #include <FIo_DirEntryImpl.h>
32 using namespace Tizen::Base;
34 namespace Tizen { namespace Io
37 _DirEntryImpl::_DirEntryImpl(void)
45 _DirEntryImpl::~_DirEntryImpl(void)
50 _DirEntryImpl::GetInstance(DirEntry* pDirEntry)
54 return pDirEntry->__pDirEntryImpl;
61 _DirEntryImpl::GetInstance(const DirEntry* pDirEntry)
65 return pDirEntry->__pDirEntryImpl;
71 _DirEntryImpl::_DirEntryImpl(const _DirEntryImpl& dirEntryImpl)
76 __dateTime = dirEntryImpl.__dateTime;
77 __fileSize = dirEntryImpl.__fileSize;
78 __name = dirEntryImpl.__name;
79 __directory = dirEntryImpl.__directory;
80 __hidden = dirEntryImpl.__hidden;
81 __readOnly = dirEntryImpl.__readOnly;
85 _DirEntryImpl::operator =(const _DirEntryImpl& dirEntryImpl)
87 if (&dirEntryImpl != this)
89 __dateTime = dirEntryImpl.__dateTime;
90 __fileSize = dirEntryImpl.__fileSize;
91 __name = dirEntryImpl.__name;
92 __directory = dirEntryImpl.__directory;
93 __hidden = dirEntryImpl.__hidden;
94 __readOnly = dirEntryImpl.__readOnly;
101 _DirEntryImpl::Equals(const Object& object) const
103 const _DirEntryImpl* pOther = dynamic_cast< const _DirEntryImpl* >(&object);
109 if (__dateTime == pOther->__dateTime && __fileSize == pOther->__fileSize &&
110 __name == pOther->__name && __directory == pOther->__directory &&
111 __hidden == pOther->__hidden && __readOnly == pOther->__readOnly)
120 _DirEntryImpl::GetHashCode(void) const
124 hashCode.Append(__dateTime.ToString());
125 hashCode.Append(static_cast< long >(__fileSize));
126 hashCode.Append(__name);
127 hashCode.Append(static_cast< int >(__directory));
128 hashCode.Append(static_cast< int >(__hidden));
129 hashCode.Append(static_cast< int >(__readOnly));
131 return hashCode.GetHashCode();
134 const Tizen::Base::String
135 _DirEntryImpl::GetName(void) const
137 SetLastResult(E_SUCCESS);
142 _DirEntryImpl::GetFileSize(void) const
144 SetLastResult(E_SUCCESS);
149 _DirEntryImpl::IsDirectory(void) const
151 SetLastResult(E_SUCCESS);
156 _DirEntryImpl::IsHidden(void) const
158 SetLastResult(E_SUCCESS);
163 _DirEntryImpl::IsReadOnly(void) const
165 SetLastResult(E_SUCCESS);
169 Tizen::Base::DateTime
170 _DirEntryImpl::GetDateTime(void) const
172 SetLastResult(E_SUCCESS);
177 _DirEntryImpl::Set(DateTime dateTime, unsigned long fileSize, String name,
178 bool dir, bool readOnly, bool hidden)
180 __dateTime = dateTime;
181 __fileSize = fileSize;
184 __readOnly = readOnly;
189 _DirEntryImpl::CreateDirEntryInstanceN(void)
191 std::unique_ptr<DirEntry> pDirEntry(new (std::nothrow) DirEntry());
192 SysTryReturn(NID_IO, pDirEntry != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
193 return pDirEntry.release();