00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef LOCATE_IMAGES_H
00013 #define LOCATE_IMAGES_H
00014
00015 #include <string>
00016 #include <map>
00017 #include <vector>
00018
00019 #include "image_errors.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class extra_images {
00030 public:
00031 extra_images();
00032
00033
00034
00035 void populate(std::vector<std::string> const & paths,
00036 std::string const & archive_path,
00037 std::string const & root_path);
00038
00039
00040 struct matcher {
00041 std::string const & value;
00042 public:
00043 explicit matcher(std::string const & v) : value(v) {}
00044 virtual ~matcher() {}
00045
00046 virtual bool operator()(std::string const & str) const {
00047 return str == value;
00048 }
00049 };
00050
00051
00052
00053
00054 std::vector<std::string> const find(matcher const & match) const;
00055
00056
00057 std::vector<std::string> const find(std::string const & name) const;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 std::string const find_image_path(std::string const & image_name,
00070 image_error & error, bool fixup) const;
00071
00072
00073 std::string get_archive_path() const { return archive_path; }
00074
00075
00076
00077 std::string strip_path_prefix(std::string const & image) const;
00078
00079
00080 int get_uid() const { return uid; }
00081
00082 private:
00083 void populate(std::vector<std::string> const & paths,
00084 std::string const & prefix_path);
00085
00086 std::string const locate_image(std::string const & image_name,
00087 image_error & error, bool fixup) const;
00088
00089 typedef std::multimap<std::string, std::string> images_t;
00090 typedef images_t::value_type value_type;
00091 typedef images_t::const_iterator const_iterator;
00092
00093
00094 images_t images;
00095
00096 std::string archive_path;
00097
00098
00099 std::string root_path;
00100
00101
00102 int uid;
00103
00104 static int suid;
00105 };
00106
00107 #endif