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_FileAttributesImpl.cpp
20 * @brief This is the implementation file for _FileAttributesImpl class.
23 #include <sys/types.h>
27 #include <FBaseString.h>
28 #include <FBaseResult.h>
30 #include <FBaseSysLog.h>
32 #include <FBase_StringConverter.h>
33 #include <FBase_NativeError.h>
34 #include <FIo_FileAttributesImpl.h>
36 using namespace Tizen::Base;
38 namespace Tizen { namespace Io
41 _FileAttributesImpl::_FileAttributesImpl(void)
49 _FileAttributesImpl::~_FileAttributesImpl(void)
53 _FileAttributesImpl::_FileAttributesImpl(const _FileAttributesImpl& fileAttributesImpl)
59 __fileSize = fileAttributesImpl.__fileSize;
60 __directory = fileAttributesImpl.__directory;
61 __hidden = fileAttributesImpl.__hidden;
62 __readOnly = fileAttributesImpl.__readOnly;
63 __creationTime = fileAttributesImpl.__creationTime;
64 __lastModifiedTime = fileAttributesImpl.__lastModifiedTime;
68 _FileAttributesImpl::operator =(const _FileAttributesImpl& fileAttributesImpl)
70 if (&fileAttributesImpl != this)
72 __fileSize = fileAttributesImpl.__fileSize;
73 __directory = fileAttributesImpl.__directory;
74 __hidden = fileAttributesImpl.__hidden;
75 __readOnly = fileAttributesImpl.__readOnly;
76 __creationTime = fileAttributesImpl.__creationTime;
77 __lastModifiedTime = fileAttributesImpl.__lastModifiedTime;
84 _FileAttributesImpl::GetInstance(FileAttributes& fileAttributes)
86 return fileAttributes.__pFileAttributesImpl;
89 const _FileAttributesImpl*
90 _FileAttributesImpl::GetInstance(const FileAttributes& fileAttributes)
92 return fileAttributes.__pFileAttributesImpl;
96 _FileAttributesImpl::Equals(const Object& object) const
98 const _FileAttributesImpl* pOther = dynamic_cast< const _FileAttributesImpl* >(&object);
104 if (__fileSize == pOther->__fileSize && __directory == pOther->__directory &&
105 __hidden == pOther->__hidden && __readOnly == pOther->__readOnly &&
106 __creationTime == pOther->__creationTime && __lastModifiedTime == pOther->__lastModifiedTime)
115 _FileAttributesImpl::GetHashCode(void) const
119 hashCode.Append(static_cast< long >(__fileSize));
120 hashCode.Append(static_cast< int >(__directory));
121 hashCode.Append(static_cast< int >(__hidden));
122 hashCode.Append(static_cast< int >(__readOnly));
123 hashCode.Append(__creationTime.ToString());
124 hashCode.Append(__lastModifiedTime.ToString());
126 return hashCode.GetHashCode();
130 _FileAttributesImpl::GetFileSize(void) const
132 SetLastResult(E_SUCCESS);
137 _FileAttributesImpl::GetDateTime(void) const
139 SetLastResult(E_SUCCESS);
140 return __creationTime;
144 _FileAttributesImpl::GetLastModifiedTime(void) const
146 SetLastResult(E_SUCCESS);
147 return __lastModifiedTime;
151 _FileAttributesImpl::IsDirectory(void) const
153 SetLastResult(E_SUCCESS);
158 _FileAttributesImpl::IsHidden(void) const
160 SetLastResult(E_SUCCESS);
165 _FileAttributesImpl::IsReadOnly(void) const
167 SetLastResult(E_SUCCESS);
172 _FileAttributesImpl::Set(const DateTime& dateTime, const DateTime& modifiedTime, off64_t fileSize,
173 unsigned long attribute, bool hidden)
175 __fileSize = fileSize;
176 __directory = S_ISDIR(attribute) ? true : false;
178 __readOnly = (attribute & (S_IWUSR)) ? false : true;
180 __creationTime = dateTime;
181 __lastModifiedTime = modifiedTime;
183 SetLastResult(E_SUCCESS);