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