40#include <BESCatalog.h>
45 static std::string rfc822_date(time_t t);
47 static std::string entity(
char c);
69 static std::string
www2id(
const std::string &in,
const std::string &escape =
"%",
const std::string &except =
"");
70 static std::string unhexstring(
const std::string& s);
73 static std::string
lowercase(
const std::string &s);
76 static std::string
unescape(
const std::string &s);
79 static void check_path(
const std::string &path,
const std::string &root,
bool follow_sym_links);
89 static std::string
id2xml(std::string in,
const std::string ¬_allowed =
"><&'\"");
92 static std::string
xml2id(std::string in);
95 static void explode(
char delim,
const std::string &str, std::list<std::string> &values);
98 static std::string
implode(
const std::list<std::string> &values,
char delim);
101 std::string protocol;
112 static std::string
assemblePath(
const std::string &firstPart,
const std::string &secondPart,
bool leadingSlash =
false,
bool trailingSlash =
false);
113 static std::string
pathConcat(
const std::string &firstPart,
const std::string &secondPart,
char separator=
'/');
115 static bool endsWith(std::string
const &fullString, std::string
const &ending);
120 static unsigned int replace_all(std::string &s, std::string find_this, std::string replace_with_this);
121 static std::string
normalize_path(
const std::string &path,
bool leading_separator,
bool trailing_separator, std::string separator =
"/");
122 static void tokenize(
const std::string& str, std::vector<std::string>& tokens,
const std::string& delimiters =
"/");
123 static std::string
get_time(
bool use_local_time =
false);
124 static std::string
get_time(time_t the_time,
bool use_local_time =
false);
125 static std::vector<std::string>
split(
const std::string &s,
char delim=
'/',
bool skip_empty=
true);
127 static BESCatalog *separateCatalogFromPath(std::string &path);
129 static uint64_t
file_to_stream(
const std::string &file_name, std::ostream &o_strm, uint64_t read_start_position=0);
134 static int mkdir_p(
const std::string &path, mode_t mode);
135 static std::string file_to_string(
const std::string &filename);
136 static std::string file_to_string(
const std::string &filename, std::string &error_msg);
137 static int make_temp_file(
const std::string &temp_file_dir, std::string &temp_file_name);
138 static void string_to_file(
const std::string &filename,
const std::string &content);
141 static std::string uuid();
Catalogs provide a hierarchical organization for data.
static std::vector< std::string > split(const std::string &s, char delim='/', bool skip_empty=true)
Splits the string s into the return vector of tokens using the delimiter delim and skipping empty val...
static void explode(char delim, const std::string &str, std::list< std::string > &values)
static long get_current_memory_usage() noexcept
Get the Resident Set Size in KB.
static void url_explode(const std::string &url_str, BESUtil::url &url_parts)
Given a url, break the url into its different parts.
static bool endsWith(std::string const &fullString, std::string const &ending)
static void tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters="/")
static std::string get_dir_name(const std::string &p)
static void set_mime_text(std::ostream &strm)
Generate an HTTP 1.0 response header for a text document.
static std::string id2xml(std::string in, const std::string ¬_allowed="><&'\"")
static void conditional_timeout_cancel()
Checks if the timeout alarm should be canceled based on the value of the BES key BES....
static void check_path(const std::string &path, const std::string &root, bool follow_sym_links)
Is the combination of root + path a pathname the BES can/should access?
static int mkdir_p(const std::string &path, mode_t mode)
static void exit_on_request_timeout()
Checks if the timeout alarm should be canceled based on the value of the BES key BES....
static unsigned int replace_all(std::string &s, std::string find_this, std::string replace_with_this)
Operates on the string 's' to replaces every occurrence of the value of the string 'find_this' with t...
static void set_mime_html(std::ostream &strm)
Generate an HTTP 1.0 response header for a html document.
static std::string lowercase(const std::string &s)
static bool is_directory(const std::string &p)
Is the given path a directory?
static std::string pathConcat(const std::string &firstPart, const std::string &secondPart, char separator='/')
Concatenate path fragments making sure that they are separated by a single '/' character.
static std::string assemblePath(const std::string &firstPart, const std::string &secondPart, bool leadingSlash=false, bool trailingSlash=false)
Assemble path fragments making sure that they are separated by a single '/' character.
static std::string www2id(const std::string &in, const std::string &escape="%", const std::string &except="")
static std::string implode(const std::list< std::string > &values, char delim)
static void trim_if_surrounding_quotes(std::string &value)
Remove double quotes around a string This function will remove a leading and/or trailing double quote...
static std::string normalize_path(const std::string &path, bool leading_separator, bool trailing_separator, std::string separator="/")
Removes duplicate separators and provides leading and trailing separators as directed.
static std::string xml2id(std::string in)
static uint64_t file_to_stream(const std::string &file_name, std::ostream &o_strm, uint64_t read_start_position=0)
Copies the contents of the file identified by file_name to the stream o_strm.
static void trim_if_trailing_slash(std::string &value)
If the string ends in a slash, remove it This function works for empty strings (doing nothing)....
static std::string unescape(const std::string &s)
static void string_to_file(const std::string &filename, const std::string &content)
Write a string to a file.
static char * fastpidconverter(char *buf, int base)
static void removeLeadingAndTrailingBlanks(std::string &key)
static std::string & remove_crlf(std::string &str)
"Sanitizes" the string by replacing any 0x0A (new line) or 0x0D (carriage return) characters with 0x2...
static int make_temp_file(const std::string &temp_file_dir, std::string &temp_file_name)
Make and open a temporary file. The file is opened such that we know it is unique and not in use by a...
static std::string get_time(bool use_local_time=false)