Skip to content

Commit

Permalink
XrdS3: add simplie 'getBucketName' function extracting bucket name fr…
Browse files Browse the repository at this point in the history
…om virtual host URI
  • Loading branch information
apeters1971 committed Jun 24, 2024
1 parent be31084 commit 952f818
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/XrdS3/XrdS3Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ std::string S3Utils::timestampToRFC7231(const struct tm *gmt) {
return std::string(buffer);
}

//------------------------------------------------------------------------------
//! extract bucket name out of virtual host
//! @param FQHN
//! @return the name of the bucket or an empty string
//------------------------------------------------------------------------------
std::string S3Utils::getBucketName(const std::string& host)
{
auto ndot = std::count(host.begin(), host.end(), '.');
if ( ndot > 2) {
// return bucket name
return host.substr(0, host.find('.'));
} else {
return "";
}
}

//------------------------------------------------------------------------------
//! make a path
//!
Expand Down
2 changes: 2 additions & 0 deletions src/XrdS3/XrdS3Utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ class S3Utils {
static std::string timestampToRFC7231(const time_t &t);
static std::string timestampToRFC7231(const tm *t);

static std::string getBucketName(const std::string& host);

static int makePath(char *path, mode_t mode);

static void RmPath(std::filesystem::path path,
Expand Down

0 comments on commit 952f818

Please sign in to comment.