9fed43c6d0600b360c2f22fa7dcdcb5b8ed9603a
[platform/framework/native/appfw.git] / src / base / utility / FBaseUtil_FileUnzipperImpl.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                FBaseUtil__FileUnzipperImplImpl.h
20  * @brief               This is the header file for _FileUnzipperImpl class.
21  *
22  * This header file contains the declarations of the _FileUnzipperImpl class.
23  */
24
25 #ifndef _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
26 #define _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
27
28 #include <limits.h>
29 #include <unique_ptr.h>
30
31 #include <FBaseString.h>
32 #include <FBaseUtilZipEntry.h>
33
34 typedef char FilePath[PATH_MAX + 1];
35
36 namespace Tizen { namespace Base { namespace Utility
37 {
38
39
40 class _FileUnzipperImpl
41         : public Tizen::Base::Object
42 {
43 public:
44         _FileUnzipperImpl(void);
45         virtual ~_FileUnzipperImpl(void);
46         result Construct(const String& filePath);
47
48         result UnzipTo(const String& dirPath) const;
49         result UnzipTo(const String& dirPath, const String& zipEntryName) const;
50         int GetEntryCount(void) const;
51         int GetFileCount(void) const;
52         int GetDirectoryCount(void) const;
53         result GetEntry(const String& zipEntryName, ZipEntry& entry) const;
54         result GetEntry(int index, ZipEntry& entry) const;
55
56         static result CreateDirectories(char* pFilePath);
57         static result IsFileExists(const char* pFilePath);
58         static bool IsFileExistsInZip(const char pArchiveName[], const char* pFilePathForZip);
59
60 private:
61         result UnzipCurrentFileTo(void* pUnZipFile, FilePath outPath, int usedBytes) const;
62         result GetCurrentFileInfo(void* pUnZipFile, ZipEntry& entry) const;
63
64 private:
65         std::unique_ptr< char[] > __pArchiveName;
66         unsigned long __entryCount;
67         unsigned long __dirCount;
68         unsigned long __fileCount;
69
70 }; // _FileUnzipperImpl
71
72 }}} // Tizen::Base::Utility
73
74 #endif // _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_