Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / src / base / utility / FBaseUtil_FileUnzipperImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseUtil__FileUnzipperImplImpl.h
19  * @brief               This is the header file for _FileUnzipperImpl class.
20  *
21  * This header file contains the declarations of the _FileUnzipperImpl class.
22  */
23 #ifndef _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
24 #define _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_
25
26 #include <limits.h>
27 #include <unique_ptr.h>
28
29 #include <FBaseString.h>
30 #include <FBaseUtilZipEntry.h>
31
32 typedef char FilePath[PATH_MAX + 1];
33
34 namespace Tizen { namespace Base { namespace Utility
35 {
36
37 class _FileUnzipperImpl
38         : public Tizen::Base::Object
39 {
40 public:
41         _FileUnzipperImpl(void);
42         virtual ~_FileUnzipperImpl(void);
43         result Construct(const String& filePath);
44
45         result UnzipTo(const String& dirPath) const;
46         result UnzipTo(const String& dirPath, const String& zipEntryName) const;
47         int GetEntryCount(void) const;
48         int GetFileCount(void) const;
49         int GetDirectoryCount(void) const;
50         result GetEntry(const String& zipEntryName, ZipEntry& entry) const;
51         result GetEntry(int index, ZipEntry& entry) const;
52
53         static result CreateDirectories(char* pFilePath);
54         static result IsFileExists(const char* pFilePath);
55         static bool IsFileExistsInZip(const char pArchiveName[], const char* pFilePathForZip);
56
57 private:
58         result UnzipCurrentFileTo(void* pUnZipFile, FilePath outPath, int usedBytes) const;
59         result GetCurrentFileInfo(void* pUnZipFile, ZipEntry& entry) const;
60
61 private:
62         std::unique_ptr< char[] > __pArchiveName;
63         unsigned long __entryCount;
64         unsigned long __dirCount;
65         unsigned long __fileCount;
66
67 }; // _FileUnzipperImpl
68 }}} // Tizen::Base::Utility
69 #endif // _FBASE_UTIL_INTERNAL_FILEUNZIPPER_IMPL_H_