6ef10e516166b9385dcf103603d161e7f7cb55a9
[platform/framework/native/appfw.git] / inc / FBaseUtilZipEntry.h
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.h
20  * @brief               This is the header file for the %ZipEntry class.
21  *
22  * This header file contains the declarations of the %ZipEntry class.
23  */
24
25 #ifndef _FBASE_UTIL_ZIP_ENTRY_H_
26 #define _FBASE_UTIL_ZIP_ENTRY_H_
27
28 #include <FBaseString.h>
29 #include <FBaseDateTime.h>
30 #include <FBaseUtilTypes.h>
31
32
33
34 namespace Tizen { namespace Base { namespace Utility
35 {
36 /**
37  * @class       ZipEntry
38  * @brief               This class provides access to the entries of a zip-archive.
39  *
40  * @since 2.0
41  *
42  * The %ZipEntry class is used for accessing the elements of a zip-archive. Each instance of
43  * %ZipEntry represents a single entry in the zip-archive.
44  * It also stores the information related to that entry, such as name, compressed size,
45  * uncompressed size, compression level, and archive name.
46  *
47  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/utility_namespace.htm">Utility</a>.
48  *
49  * The following example demonstrates how to use the %ZipEntry class.
50  *
51  * @code
52  *      #include <FBase.h>
53  *
54  *      using namespace Tizen::App;
55  *      using namespace Tizen::Base;
56  *      using namespace Tizen::Base::Utility;
57  *
58  *      void
59  *      MyClass::FileZipSample(void)
60  *      {
61  *              String str;
62  *              int i = 0, count = 0;
63  *              unsigned long size = 0;
64  *              ZipEntry entry;
65  *
66  *              FileUnzip unzip;
67  *              String dataPath = App::GetInstance()->GetAppDataPath();
68  *              unzip.Construct(dataPath + L"sample.zip");
69  *
70  *              count = unzip.GetEntryCount();
71  *
72  *              for (i = 0; i < count; i++)
73  *              {
74  *                      // Gets a ZipEntry from the zip-archive
75  *                      unzip.GetEntry(i, entry);
76  *
77  *                      // Gets an entry name associated with the ZipEntry
78  *                      str = entry.GetName();
79  *
80  *                      // Gets the name of the zip file which ZipEntry belongs to
81  *                      str = entry.GetArchiveName();
82  *
83  *                      // Gets the compressed size of ZipEntry
84  *                      size = entry.GetCompressedSize();
85  *              }
86  *
87  *      }
88  * @endcode
89  */
90 class _OSP_EXPORT_ ZipEntry
91         : public Tizen::Base::Object
92 {
93 public:
94         /**
95          * This is the default constructor for this class.
96          *
97          * @since 2.0
98          */
99         ZipEntry(void);
100
101         /**
102          * This destructor overrides Tizen::Base::Object::~Object().
103          *
104          * @since 2.0
105          */
106         virtual ~ZipEntry(void);
107
108         /**
109          * Gets an entry name associated with a zip entry. @n
110          * It can be a file or directory name.
111          *
112          * @since 2.0
113          *
114          * @return              An entry name
115          *
116          */
117         String GetName(void) const;
118
119         /**
120          * Gets the compression level associated with a zip entry.
121          *
122          * @since 2.0
123          *
124          * @return              The compression level associated with a zip entry
125          *
126          */
127         CompressionLevel GetCompressionLevel(void) const;
128
129         /**
130          * Checks whether a zip entry is a file or directory.
131          *
132          * @since 2.0
133          *
134          * @return              @c true if the entry is a directory, @n
135          *                              else @c false
136          */
137         bool IsDirectory(void) const;
138
139         /**
140          * Gets the compressed size of a zip entry.
141          *
142          * @since 2.0
143          *
144          * @return              The compressed size of a zip entry
145          */
146         unsigned long GetCompressedSize(void) const;
147
148         /**
149          * Gets the uncompressed size of a zip entry.
150          *
151          * @since 2.0
152          *
153          * @return              The uncompressed size of a zip entry
154          */
155         unsigned long GetUncompressedSize(void) const;
156
157         /**
158          * Gets the name of a zip file to which %ZipEntry belongs.
159          *
160          * @since 2.0
161          *
162          * @return              The name of a zip file
163          * @remarks     This method returns the name of a zip file that is opened
164          * in the FileUnzipper::Construct() method.
165          */
166         String GetArchiveName(void) const;
167
168         /**
169          * Compares the specified instance to the calling instance.
170          *
171          * @since 2.0
172          *
173          * @return              @c true if the specified instance equals the current instance, @n
174          *                              else @c false
175          * @param[in]   obj     The object to compare with the current instance
176          * @remarks     The method returns @c true if all the attributes in the instance are same.
177          */
178         virtual bool Equals(const Tizen::Base::Object& obj) const;
179
180         /**
181          * Gets the hash value of the current instance.
182          *
183          * @since 2.0
184          *
185          * @return              The hash value of the current instance
186          */
187         virtual int GetHashCode(void) const;
188
189
190 private:
191         /**
192          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
193          *
194          * @since 2.0
195          *
196          * @param[in]   entry  The instance of the %ZipEntry class to copy from
197          * @remarks             This constructor is hidden.
198          */
199         ZipEntry(const ZipEntry& entry);
200
201         /**
202          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
203          *
204          * @since 2.0
205          *
206          * @param[in]   entry   An instance of %ZipEntry
207          * @remarks             This operator is hidden.
208          */
209         ZipEntry& operator =(const ZipEntry& entry);
210
211         void Set(void* unzFile);
212
213
214         String __name;
215         void* __unzFile;
216         CompressionLevel __compressionLevel;
217
218         friend class _FileUnzipperImpl;
219
220         friend class _ZipEntryImpl;
221         class _ZipEntryImpl* __pZipEntryImpl;
222
223 }; // ZipEntry
224
225 }}} // Tizen::Base::Utility
226
227 #endif // _FBASE_UTIL_ZIP_ENTRY_H_