Esempio n. 1
0
std::string join( const std::vector<std::string>& array, const std::string& sep)
{
  vector<string>::const_iterator sequence = array.begin( );
  vector<string>::const_iterator end_sequence = array.end( );
  if(sequence == end_sequence) return "";

  string joinstring( "" );
  if (sequence != end_sequence) {
    joinstring += *sequence;
    ++sequence;
  }

  for( ; sequence != end_sequence; ++sequence )
    joinstring += sep + *sequence;
  
  return joinstring;
}
Esempio n. 2
0
int load_package_signature(struct pkg *pkg, int dirfd)
{
    struct file_t file;
    _cleanup_free_ char *signame = joinstring(pkg->filename, ".sig", NULL);
    _cleanup_close_ int fd = openat(dirfd, signame, O_RDONLY);

    if (fd < 0)
        return -1;

    if (file_from_fd(&file, fd) < 0)
        return -1;

    base64_encode((unsigned char **)&pkg->base64sig,
                  (const unsigned char *)file.mmap, file.st.st_size);

    if (file.st.st_mtime > pkg->mtime)
        file.st.st_mtime = pkg->mtime;

    file_close(&file);
    return 0;
}
Esempio n. 3
0
std::string join( const std::vector<long int>& array, const std::string& sep)
{
  vector<long int>::const_iterator sequence = array.begin( );
  vector<long int>::const_iterator end_sequence = array.end( );
  if(sequence == end_sequence) return "";

  string joinstring( "" );
  if (sequence != end_sequence) {
    ostringstream tmp( "" );
    tmp << *sequence;
    joinstring += tmp.str( );//*sequence;
    ++sequence;
  }

  for( ; sequence != end_sequence; ++sequence ) {
  
    ostringstream tmp( "" );
    tmp << *sequence;
  
    joinstring += sep + tmp.str( );//*sequence;
  }
  
  return joinstring;
}