mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Consolidate lower and upper logic (#2594)
This commit is contained in:
parent
a101b88114
commit
45b32046cd
@ -593,8 +593,7 @@ size_t S3fsCurl::HeaderCallback(void* data, size_t blockSize, size_t numBlocks,
|
||||
|
||||
if(getline(ss, key, ':')){
|
||||
// Force to lower, only "x-amz"
|
||||
std::string lkey = key;
|
||||
transform(lkey.cbegin(), lkey.cend(), lkey.begin(), static_cast<int (*)(int)>(std::tolower));
|
||||
std::string lkey = lower(key);
|
||||
if(is_prefix(lkey.c_str(), "x-amz")){
|
||||
key = lkey;
|
||||
}
|
||||
@ -746,9 +745,8 @@ acl_t S3fsCurl::GetDefaultAcl()
|
||||
std::string S3fsCurl::SetStorageClass(const std::string& storage_class)
|
||||
{
|
||||
std::string old = S3fsCurl::storage_class;
|
||||
S3fsCurl::storage_class = storage_class;
|
||||
// AWS requires uppercase storage class values
|
||||
transform(S3fsCurl::storage_class.cbegin(), S3fsCurl::storage_class.cend(), S3fsCurl::storage_class.begin(), ::toupper);
|
||||
S3fsCurl::storage_class = upper(storage_class);
|
||||
return old;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
@ -98,10 +99,13 @@ off_t cvt_strtoofft(const char* str, int base)
|
||||
|
||||
std::string lower(std::string s)
|
||||
{
|
||||
// change each character of the std::string to lower case
|
||||
for(size_t i = 0; i < s.length(); i++){
|
||||
s[i] = static_cast<char>(tolower(s[i]));
|
||||
}
|
||||
std::transform(s.cbegin(), s.cend(), s.begin(), ::tolower);
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string upper(std::string s)
|
||||
{
|
||||
std::transform(s.cbegin(), s.cend(), s.begin(), ::toupper);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,7 @@ std::string trim_left(std::string s, const char *t = SPACES);
|
||||
std::string trim_right(std::string s, const char *t = SPACES);
|
||||
std::string trim(std::string s, const char *t = SPACES);
|
||||
std::string lower(std::string s);
|
||||
std::string upper(std::string s);
|
||||
std::string peeloff(std::string s);
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user