#pragma once #include #include #include namespace util { // True if every character is a lowercase hex digit and the length is plausible // for an abbreviated or full git object id. bool is_hex_oid(const std::string &s); // Human readable byte size, e.g. "1.2 KiB". std::string human_size(uint64_t bytes); // UTC timestamp formatted as "YYYY-MM-DD HH:MM". std::string format_time(std::time_t t); // Last path component of a '/'-separated path. std::string basename(const std::string &path); // Everything before the last '/', or "" if there is no '/'. std::string parent_path(const std::string &path); // Remove leading and trailing '/' characters. std::string trim_slashes(const std::string &path); // Whether author/committer/tagger email addresses may be shown. False unless // the SHOW_EMAILS environment variable is "1". Evaluated once. bool show_emails(); // True for paths ending in a markdown extension (.md, .markdown), case // insensitive. bool is_markdown_path(const std::string &path); // MIME type for a recognised image path by extension (e.g. "image/png"), or // "" when the path is not a recognised image. Case insensitive. std::string image_mime_type(const std::string &path); } // namespace util