sync with tizen_2.0
[platform/framework/native/appfw.git] / src / base / utility / FBaseUtilZipEntry.cpp
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                FBaseUtilZipEntry.cpp
20  * @brief               This is the implementation file for ZipEntry class.
21  */
22
23 //Includes
24 #include <FBaseUtilZipEntry.h>
25
26 #include "FBaseUtil_ZipEntryInfo.h"
27
28 namespace Tizen { namespace Base { namespace Utility
29 {
30
31
32 ZipEntry::ZipEntry(void)
33         : __unzFile(null)
34         , __compressionLevel(DEFAULT_COMPRESSION)
35         , __pZipEntryImpl(null)
36 {
37 }
38
39
40 ZipEntry::~ZipEntry(void)
41 {
42         if (__unzFile)
43         {
44                 delete static_cast <_ZipEntryInfo*>(__unzFile);
45                 __unzFile = null;
46         }
47 }
48
49
50 String
51 ZipEntry::GetName(void) const
52 {
53         return __name;
54 }
55
56
57 CompressionLevel
58 ZipEntry::GetCompressionLevel(void) const
59 {
60         return __compressionLevel;
61 }
62
63
64 bool
65 ZipEntry::IsDirectory(void) const
66 {
67         _ZipEntryInfo* pZipEntryInfo = static_cast <_ZipEntryInfo*>(__unzFile);
68         return pZipEntryInfo->__isDirectory;
69 }
70
71
72 unsigned long
73 ZipEntry::GetCompressedSize(void) const
74 {
75         _ZipEntryInfo* pZipEntryInfo = static_cast <_ZipEntryInfo*>(__unzFile);
76         return pZipEntryInfo->__compressedSize;
77 }
78
79
80 unsigned long
81 ZipEntry::GetUncompressedSize(void) const
82 {
83         _ZipEntryInfo* pZipEntryInfo = static_cast <_ZipEntryInfo*>(__unzFile);
84         return pZipEntryInfo->__uncompressedSize;
85 }
86
87
88 String
89 ZipEntry::GetArchiveName(void) const
90 {
91         _ZipEntryInfo* pZipEntryInfo = static_cast <_ZipEntryInfo*>(__unzFile);
92         return pZipEntryInfo->__archiveName;
93 }
94
95
96 bool
97 ZipEntry::Equals(const Tizen::Base::Object& obj) const
98 {
99         const ZipEntry* pOther = dynamic_cast <const ZipEntry*>(&obj);
100
101         if (pOther != null)
102         {
103                 if (!GetArchiveName().Equals(pOther->GetArchiveName(), true))
104                 {
105                         return false;
106                 }
107
108                 if (__compressionLevel != pOther->__compressionLevel)
109                 {
110                         return false;
111                 }
112
113                 if (__name != pOther->__name)
114                 {
115                         return false;
116                 }
117         }
118         return true;
119
120 }
121
122
123 int
124 ZipEntry::GetHashCode(void) const
125 {
126         return (int) this;
127 }
128
129
130 void
131 ZipEntry::Set(void* unzFile)
132 {
133         _ZipEntryInfo* pZipEntryInfo = static_cast <_ZipEntryInfo*>(unzFile);
134         __name = pZipEntryInfo->__name;
135         __unzFile = pZipEntryInfo;
136         __compressionLevel = pZipEntryInfo->__compressionLevel;
137 }
138
139
140 } } } // Tizen::Base::Utility