7 #ifndef _FCITX_UTILS_STANDARDPATHS_H_ 8 #define _FCITX_UTILS_STANDARDPATHS_H_ 10 #include <sys/types.h> 18 #include <unordered_map> 20 #include <fcitx-utils/fcitxutils_export.h> 22 #include <fcitx-utils/macros.h> 38 class StandardPathsPrivate;
50 enum class StandardPathsMode : uint8_t {
53 Default = User | System,
65 SkipUserPath = (1 << 0),
66 SkipSystemPath = (1 << 1),
67 SkipBuiltInPath = (1 << 2),
72 using StandardPathsFilterCallback =
73 std::function<bool(const std::filesystem::path &)>;
75 namespace pathfilter {
77 static inline auto extension(
const std::string &ext) {
78 return [ext](
const std::filesystem::path &path) {
79 return path.extension() == ext;
95 const std::string &packageName,
96 const std::unordered_map<
97 std::string, std::vector<std::filesystem::path>> &builtInPath,
113 static std::filesystem::path
114 fcitxPath(
const char *path,
const std::filesystem::path &subPath = {});
116 static std::filesystem::path
117 findExecutable(
const std::filesystem::path &name);
119 static bool hasExecutable(
const std::filesystem::path &name);
131 std::span<const std::filesystem::path>
136 std::filesystem::path
146 std::vector<std::filesystem::path>
151 std::map<std::filesystem::path, std::filesystem::path>
153 const StandardPathsFilterCallback &callback,
163 std::filesystem::path *outPath =
nullptr)
const;
172 static UnixFD openPath(
const std::filesystem::path &path,
173 std::optional<int> flags = std::nullopt,
174 std::optional<mode_t> mode = std::nullopt);
181 std::vector<std::filesystem::path> *outPath =
nullptr)
const;
194 const std::function<
bool(
int)> &callback)
const;
206 void syncUmask()
const;
215 bool skipBuiltInPath()
const;
221 bool skipUserPath()
const;
226 bool skipSystemPath()
const;
238 std::unique_ptr<StandardPathsPrivate> d_ptr;
242 template <
typename T>
247 #endif // _FCITX_UTILS_STANDARDPATHS_H_ Class wrap around the unix fd.
StandardPathsOption
Options for standard paths.
StandardPathsType
Enum for location type.
Utility class to handle unix file decriptor.
Class provides bit flag support for Enum.
Helper template class to make easier to use type safe enum flags.