17 #ifndef GAZEBO_COMMON_COMMONIFACE_HH_ 
   18 #define GAZEBO_COMMON_COMMONIFACE_HH_ 
   22 #include <boost/uuid/sha1.hpp> 
   48     std::string 
find_file(
const std::string &_file);
 
   56     std::string 
find_file(
const std::string &_file,
 
   57                           bool _searchLocalPath);
 
   70     std::string 
get_sha1(
const T &_buffer);
 
   76     const char *
getEnv(
const char *_name);
 
   87     bool exists(
const std::string &_path);
 
   99     bool isFile(
const std::string &_path);
 
  105     std::string 
absPath(
const std::string &_path);
 
  112     bool copyFile(
const std::string &_existingFilename,
 
  113                   const std::string &_newFilename);
 
  120     bool moveFile(
const std::string &_existingFilename,
 
  121                   const std::string &_newFilename);
 
  133                     const std::string &_orig,
 
  134                     const std::string &_key,
 
  135                     const std::string &_replacement);
 
  146     std::string 
replaceAll(
const std::string &_orig,
 
  147                            const std::string &_key,
 
  148                            const std::string &_replacement);
 
  155     std::vector<std::string> 
split(
const std::string &_str,
 
  156                                    const std::string &_delim);
 
  167                                  const std::string &_extension);
 
  176     boost::uuids::detail::sha1 sha1;
 
  177     unsigned int hash[5];
 
  178     std::stringstream stream;
 
  180     if (_buffer.size() == 0)
 
  182       sha1.process_bytes(
nullptr, 0);
 
  186       sha1.process_bytes(&(_buffer[0]), _buffer.size() * 
sizeof(_buffer[0]));
 
  189     sha1.get_digest(hash);
 
  191     for (std::size_t i = 0; i < 
sizeof(hash) / 
sizeof(hash[0]); ++i)
 
  193       stream << std::setfill(
'0')
 
  194              << std::setw(
sizeof(hash[0]) * 2)
 
std::string get_sha1(const T &_buffer)
Compute the SHA1 hash of an array of bytes. 
Definition: CommonIface.hh:174
const char * getEnv(const char *_name)
Cross platform retrieval of an environment variable. 
std::vector< std::string > split(const std::string &_str, const std::string &_delim)
Splits a string into tokens. 
std::string find_file_path(const std::string &_file)
search for a file in common::SystemPaths 
void load()
Load the common library. 
bool isFile(const std::string &_path)
Check if the given path is a file. 
bool copyFile(const std::string &_existingFilename, const std::string &_newFilename)
Copy a file. 
std::string cwd()
Get the current working directory. 
std::string absPath(const std::string &_path)
Get the absolute path of a provided path. 
std::string unique_file_path(const std::string &_pathAndName, const std::string &_extension)
Generates a path for a file which doesn't collide with existing files, by appending numbers to it (i...
std::string find_file(const std::string &_file)
search for file in common::SystemPaths 
bool isDirectory(const std::string &_path)
Check if the given path is a directory. 
bool moveFile(const std::string &_existingFilename, const std::string &_newFilename)
Move a file. 
void add_search_path_suffix(const std::string &_suffix)
add path sufix to common::SystemPaths 
void replaceAll(std::string &_result, const std::string &_orig, const std::string &_key, const std::string &_replacement)
Replace all occurances of _key with _replacement. 
bool exists(const std::string &_path)
Returns true if _path is a file or directory.