CARDS 2.4.140
Package manager for the NuTyX GNU/Linux distribution
archive_utils.h
1//
2// archive_utils.h
3//
4// Copyright (c) 2002 by Johannes Winkelmann
5// Copyright (c) 2013 - 2020 by NuTyX team (http://nutyx.org)
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20// USA.
21//
22
23#ifndef ARCHIVEUTILS_H
24#define ARCHIVEUTILS_H
25
26#include "string_utils.h"
27
28#include <archive.h>
29#include <archive_entry.h>
30
31
32#if ARCHIVE_VERSION_NUMBER >= 3000000
33#define INIT_ARCHIVE(ar) \
34 archive_read_support_filter_gzip((ar)); \
35 archive_read_support_filter_bzip2((ar)); \
36 archive_read_support_filter_xz((ar)); \
37 archive_read_support_filter_zstd((ar)); \
38 archive_read_support_format_tar((ar))
39#define FREE_ARCHIVE(ar) \
40 archive_read_free((ar))
41#else
42#define INIT_ARCHIVE(ar) \
43 archive_read_support_compression_gzip((ar)); \
44 archive_read_support_compression_bzip2((ar)); \
45 archive_read_support_compression_xz((ar)); \
46 archive_read_support_format_tar((ar))
47#define FREE_ARCHIVE(ar) \
48 archive_read_finish((ar))
49#endif
50
51#define DEFAULT_BYTES_PER_BLOCK (20 * 512)
52#define METAFILE ".META"
53#define INFOFILE ".INFO"
54#define MTREEFILE ".MTREE"
55
56enum archive_error
57{
58CANNOT_OPEN_ARCHIVE,
59CANNOT_READ_ARCHIVE,
60CANNOT_FIND_META_FILE,
61CANNOT_FIND_MTREE_FILE,
62CANNOT_FIND_NAME,
63CANNOT_FIND_ARCH,
64EMPTY_ARCHIVE
65};
66
67
69{
70 public:
71
72
73 ArchiveUtils(const std::string& fileName);
74 virtual ~ArchiveUtils();
75
76 virtual void treatErrors(const std::string& s) const;
77
78 void printDeps(); // Print Out the dependencies
79 void printMeta(); // Print Out the .META file
80 void printInfo(); // the .INFO file
81 void list(); // list the files to stdio
82
83
84 unsigned int long size(); // Numbers of files in the archive
85 std::set<std::string> setofFiles(); // return a order set of string
86 std::set<std::string> listofDependencies(); // return an order set of dependencies
87 std::set<std::string> listofAlias(); // return the alias list
88 std::set<std::pair<std::string,time_t> > listofDependenciesBuildDate(); // return an order set of dependencies,BuildDate
89 std::string arch(); // return the arch of the package
90 std::string version(); // return the version of the package
91 int release(); // return the release of the package
92 std::string description();// return the description of the package
93 std::string url(); // return the url of the package
94 std::string contributors(); // return the Contributor(s) of the package
95 std::string maintainer(); // return the Maintainer(s) of the package
96 std::string collection(); // return the collection of the package
97 std::string packager(); // return the Packager(s) of the package
98 std::string builddate(); // return the date like Mon Mar 24 10:16:00 2014
99 std::string name(); // return the name of the package
100 std::string group(); // return the group of the package
101 std::string namebuildn(); // return the name + epochvalue
102 std::string epochBuildDate(); // return the epochvalue in string format
103 time_t buildn(); // return the epoch value
104
105 private:
106
107 std::string getPackageName();
108 std::string getPackageArch();
109 std::vector<std::string> extractFileContent(const char * fileName);
110 void getRunTimeDependencies();
111 void getRunTimeDependenciesEpoch();
112 void getAliasList();
113
114 unsigned int long m_size;
115
116 std::vector<std::string> m_contentMtree;
117 std::vector<std::string> m_contentMeta;
118 std::vector<std::string> m_contentInfo;
119
120 std::set<std::string> m_rtDependenciesList;
121 std::set<std::pair<std::string,time_t> > m_rtDependenciesEpochList;
122 std::string m_fileName;
123 std::string m_packageName;
124 std::string m_packageArch;
125 std::set<std::string> m_filesList;
126 std::set<std::string> m_aliasList;
127
128 archive_error m_actualError;
129};
130
131int openArchive(const char *fileName);
132
133#endif /* ARCHIVEUTILS_H */
134// vim:set ts=2 :
Definition: archive_utils.h:69