cprover
jar_file.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Jar file reader
4 
5 Author: Diffblue Ltd
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_JAVA_BYTECODE_JAR_FILE_H
10 #define CPROVER_JAVA_BYTECODE_JAR_FILE_H
11 
12 #include <unordered_map>
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include <util/optional.h>
18 
19 #include "mz_zip_archive.h"
20 
22 
24 class jar_filet final
25 {
26 public:
31  jar_filet(java_class_loader_limitt &limit, const std::string &filename);
32 
38  jar_filet(java_class_loader_limitt &limit, const void *data, size_t size);
39 
40  jar_filet(const jar_filet &)=delete;
41  jar_filet &operator=(const jar_filet &)=delete;
42  jar_filet(jar_filet &&);
44  ~jar_filet()=default;
45 
49  optionalt<std::string> get_entry(const std::string &filename);
50 
52  std::unordered_map<std::string, std::string> get_manifest();
53 
55  std::vector<std::string> filenames() const;
56 
57 private:
61 
63 
65  std::unordered_map<std::string, size_t> m_name_to_index;
66 };
67 
68 #endif // CPROVER_JAVA_BYTECODE_JAR_FILE_H
jar_filet(java_class_loader_limitt &limit, const std::string &filename)
Open java file for reading.
Definition: jar_file.cpp:32
~jar_filet()=default
std::vector< std::string > filenames() const
Get list of filenames in the archive.
Definition: jar_file.cpp:123
optionalt< std::string > get_entry(const std::string &filename)
Get contents of a file in the jar archive.
Definition: jar_file.cpp:65
std::unordered_map< std::string, size_t > m_name_to_index
Map of filename to the file index in the zip archive.
Definition: jar_file.h:65
nonstd::optional< T > optionalt
Definition: optional.h:35
Thin object-oriented wrapper around the MZ Zip library Zip file reader and extractor.
Class representing a .jar archive.
Definition: jar_file.h:24
jar_filet & operator=(const jar_filet &)=delete
mz_zip_archivet m_zip_archive
Definition: jar_file.h:62
void initialize_file_index(java_class_loader_limitt &limit)
Loads the fileindex (m_name_to_index) with a map of loaded files to indices.
Definition: jar_file.cpp:19
std::unordered_map< std::string, std::string > get_manifest()
Get contents of the Manifest file in the jar archive.
Definition: jar_file.cpp:99
Definition: kdev_t.h:24