Init basesystem source codes.
[staging/basesystem.git] / systemservice / logger_service / server / include / ss_logger_error_event_archive.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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 /// \ingroup  tag_SS_LoggerService
19 /// \brief    This file supports error event logging.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
23 #define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_
24
25 #include <native_service/frameworkunified_types.h>
26 #include <native_service/frameworkunified_framework_if.h>
27
28 #include <libtar_listhash.h>
29 #include <libtar.h>
30
31 #include <system_service/ss_system_types.h>
32 #include <string>
33 #include <vector>
34
35 class CErrorEventArchive {
36  public:
37   CErrorEventArchive();
38   ~CErrorEventArchive();
39
40   EFrameworkunifiedStatus openArchive(std::string f_pathAndName);
41
42   EFrameworkunifiedStatus addToArchive(std::vector<std::string> f_filePathAndNameList);
43
44   EFrameworkunifiedStatus addToArchive(std::string f_filePathAndName,
45                           std::string f_destinationName, UI_8 f_depth =
46                               CErrorEventArchive::MAX_DIRECTORY_DEPTH);
47
48   EFrameworkunifiedStatus closeArchive(void);
49
50   static SI_32 gzOpenArchive(PCHAR f_pcPathname, SI_32 f_siOflags,
51                              SI_32 f_siMode);
52
53   static SI_32 gzCloseArchive();
54
55   static ssize_t gzWriteArchive(int fd, const void* buf, size_t count);
56
57   static ssize_t gzReadArchive(int fd, void* buf, size_t count);
58
59   static const UI_8 MAX_DIRECTORY_DEPTH = 4;
60
61  private:
62   EFrameworkunifiedStatus addFileToArchive(std::string f_filename,
63                               std::string f_destinationName);
64
65   EFrameworkunifiedStatus addDirectoryToArchive(std::string f_path,
66                                    std::string f_destinationName, UI_8 f_depth =
67                                        CErrorEventArchive::MAX_DIRECTORY_DEPTH);
68
69   tartype_t m_gztype;
70   TAR *m_pTarInfo;
71   std::string m_pathAndName;
72   std::string m_tmpName;
73
74   static const UI_32 TARMODE = 0644;
75 };
76
77 #endif  // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_ARCHIVE_H_