mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-02-02 18:48:26 +00:00
Merge pull request #1390 from gaul/namespace-std
Remove uses of implicit namespace std
This commit is contained in:
commit
c7132b7f56
@ -28,8 +28,6 @@
|
||||
#include "addhead.h"
|
||||
#include "curl_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Symbols
|
||||
//-------------------------------------------------------------------
|
||||
@ -69,14 +67,14 @@ bool AdditionalHeader::Load(const char* file)
|
||||
}
|
||||
Unload();
|
||||
|
||||
ifstream AH(file);
|
||||
std::ifstream AH(file);
|
||||
if(!AH.good()){
|
||||
S3FS_PRN_WARN("Could not open file(%s).", file);
|
||||
return false;
|
||||
}
|
||||
|
||||
// read file
|
||||
string line;
|
||||
std::string line;
|
||||
ADDHEAD *paddhead;
|
||||
while(getline(AH, line)){
|
||||
if('#' == line[0]){
|
||||
@ -86,10 +84,10 @@ bool AdditionalHeader::Load(const char* file)
|
||||
continue;
|
||||
}
|
||||
// load a line
|
||||
istringstream ss(line);
|
||||
string key; // suffix(key)
|
||||
string head; // additional HTTP header
|
||||
string value; // header value
|
||||
std::istringstream ss(line);
|
||||
std::string key; // suffix(key)
|
||||
std::string head; // additional HTTP header
|
||||
std::string value; // header value
|
||||
if(0 == isblank(line[0])){
|
||||
ss >> key;
|
||||
}
|
||||
@ -114,7 +112,7 @@ bool AdditionalHeader::Load(const char* file)
|
||||
if(0 == strncasecmp(key.c_str(), ADD_HEAD_REGEX, strlen(ADD_HEAD_REGEX))){
|
||||
// regex
|
||||
if(key.size() <= strlen(ADD_HEAD_REGEX)){
|
||||
S3FS_PRN_ERR("file format error: %s key(suffix) does not have key string.", key.c_str());
|
||||
S3FS_PRN_ERR("file format error: %s key(suffix) does not have key std::string.", key.c_str());
|
||||
delete paddhead;
|
||||
continue;
|
||||
}
|
||||
@ -239,30 +237,30 @@ bool AdditionalHeader::Dump() const
|
||||
return true;
|
||||
}
|
||||
|
||||
ostringstream ssdbg;
|
||||
int cnt = 1;
|
||||
std::ostringstream ssdbg;
|
||||
int cnt = 1;
|
||||
|
||||
ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << endl;
|
||||
ssdbg << "Additional Header list[" << addheadlist.size() << "] = {" << std::endl;
|
||||
|
||||
for(addheadlist_t::const_iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter, ++cnt){
|
||||
const ADDHEAD *paddhead = *iter;
|
||||
|
||||
ssdbg << " [" << cnt << "] = {" << endl;
|
||||
ssdbg << " [" << cnt << "] = {" << std::endl;
|
||||
|
||||
if(paddhead){
|
||||
if(paddhead->pregex){
|
||||
ssdbg << " type\t\t--->\tregex" << endl;
|
||||
ssdbg << " type\t\t--->\tregex" << std::endl;
|
||||
}else{
|
||||
ssdbg << " type\t\t--->\tsuffix matching" << endl;
|
||||
ssdbg << " type\t\t--->\tsuffix matching" << std::endl;
|
||||
}
|
||||
ssdbg << " base string\t--->\t" << paddhead->basestring << endl;
|
||||
ssdbg << " add header\t--->\t" << paddhead->headkey << ": " << paddhead->headvalue << endl;
|
||||
ssdbg << " base std::string\t--->\t" << paddhead->basestring << std::endl;
|
||||
ssdbg << " add header\t--->\t" << paddhead->headkey << ": " << paddhead->headvalue << std::endl;
|
||||
}
|
||||
ssdbg << " }" << endl;
|
||||
ssdbg << " }" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
ssdbg << "}" << endl;
|
||||
ssdbg << "}" << std::endl;
|
||||
|
||||
// print all
|
||||
S3FS_PRN_DBG("%s", ssdbg.str().c_str());
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "autolock.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Class AutoLock
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "bodydata.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Variables
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -32,8 +32,6 @@
|
||||
#include "autolock.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility
|
||||
//-------------------------------------------------------------------
|
||||
@ -241,10 +239,10 @@ void StatCache::Clear()
|
||||
S3FS_MALLOCTRIM(0);
|
||||
}
|
||||
|
||||
bool StatCache::GetStat(const string& key, struct stat* pst, headers_t* meta, bool overcheck, const char* petag, bool* pisforce)
|
||||
bool StatCache::GetStat(const std::string& key, struct stat* pst, headers_t* meta, bool overcheck, const char* petag, bool* pisforce)
|
||||
{
|
||||
bool is_delete_cache = false;
|
||||
string strpath = key;
|
||||
std::string strpath = key;
|
||||
|
||||
AutoLock lock(&StatCache::stat_cache_lock);
|
||||
|
||||
@ -271,11 +269,11 @@ bool StatCache::GetStat(const string& key, struct stat* pst, headers_t* meta, bo
|
||||
return false;
|
||||
}
|
||||
// hit without checking etag
|
||||
string stretag;
|
||||
std::string stretag;
|
||||
if(petag){
|
||||
// find & check ETag
|
||||
for(headers_t::iterator hiter = ent->meta.begin(); hiter != ent->meta.end(); ++hiter){
|
||||
string tag = lower(hiter->first);
|
||||
std::string tag = lower(hiter->first);
|
||||
if(tag == "etag"){
|
||||
stretag = hiter->second;
|
||||
if('\0' != petag[0] && 0 != strcmp(petag, stretag.c_str())){
|
||||
@ -323,10 +321,10 @@ bool StatCache::GetStat(const string& key, struct stat* pst, headers_t* meta, bo
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StatCache::IsNoObjectCache(const string& key, bool overcheck)
|
||||
bool StatCache::IsNoObjectCache(const std::string& key, bool overcheck)
|
||||
{
|
||||
bool is_delete_cache = false;
|
||||
string strpath = key;
|
||||
bool is_delete_cache = false;
|
||||
std::string strpath = key;
|
||||
|
||||
if(!IsCacheNoObject){
|
||||
return false;
|
||||
@ -402,8 +400,8 @@ bool StatCache::AddStat(const std::string& key, headers_t& meta, bool forcedir,
|
||||
SetStatCacheTime(ent->cache_date); // Set time.
|
||||
//copy only some keys
|
||||
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
|
||||
string tag = lower(iter->first);
|
||||
string value = iter->second;
|
||||
std::string tag = lower(iter->first);
|
||||
std::string value = iter->second;
|
||||
if(tag == "content-type"){
|
||||
ent->meta[iter->first] = value;
|
||||
}else if(tag == "content-length"){
|
||||
@ -437,7 +435,7 @@ bool StatCache::AddStat(const std::string& key, headers_t& meta, bool forcedir,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StatCache::AddNoObjectCache(const string& key)
|
||||
bool StatCache::AddNoObjectCache(const std::string& key)
|
||||
{
|
||||
if(!IsCacheNoObject){
|
||||
return true; // pretend successful
|
||||
@ -582,12 +580,12 @@ bool StatCache::DelStat(const char* key, bool lock_already_held)
|
||||
AutoLock lock(&StatCache::stat_cache_lock, lock_already_held ? AutoLock::ALREADY_LOCKED : AutoLock::NONE);
|
||||
|
||||
stat_cache_t::iterator iter;
|
||||
if(stat_cache.end() != (iter = stat_cache.find(string(key)))){
|
||||
if(stat_cache.end() != (iter = stat_cache.find(std::string(key)))){
|
||||
delete (*iter).second;
|
||||
stat_cache.erase(iter);
|
||||
}
|
||||
if(0 < strlen(key) && 0 != strcmp(key, "/")){
|
||||
string strpath = key;
|
||||
std::string strpath = key;
|
||||
if('/' == strpath[strpath.length() - 1]){
|
||||
// If there is "path" cache, delete it.
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
@ -605,10 +603,10 @@ bool StatCache::DelStat(const char* key, bool lock_already_held)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StatCache::GetSymlink(const string& key, string& value)
|
||||
bool StatCache::GetSymlink(const std::string& key, std::string& value)
|
||||
{
|
||||
bool is_delete_cache = false;
|
||||
const string& strpath = key;
|
||||
const std::string& strpath = key;
|
||||
|
||||
AutoLock lock(&StatCache::stat_cache_lock);
|
||||
|
||||
@ -639,7 +637,7 @@ bool StatCache::GetSymlink(const string& key, string& value)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StatCache::AddSymlink(const string& key, const string& value)
|
||||
bool StatCache::AddSymlink(const std::string& key, const std::string& value)
|
||||
{
|
||||
if(CacheSize< 1){
|
||||
return true;
|
||||
@ -741,7 +739,7 @@ bool StatCache::DelSymlink(const char* key, bool lock_already_held)
|
||||
AutoLock lock(&StatCache::stat_cache_lock, lock_already_held ? AutoLock::ALREADY_LOCKED : AutoLock::NONE);
|
||||
|
||||
symlink_cache_t::iterator iter;
|
||||
if(symlink_cache.end() != (iter = symlink_cache.find(string(key)))){
|
||||
if(symlink_cache.end() != (iter = symlink_cache.find(std::string(key)))){
|
||||
delete iter->second;
|
||||
symlink_cache.erase(iter);
|
||||
}
|
||||
|
@ -29,22 +29,20 @@
|
||||
#include "s3fs_auth.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility Function
|
||||
//-------------------------------------------------------------------
|
||||
string s3fs_get_content_md5(int fd)
|
||||
std::string s3fs_get_content_md5(int fd)
|
||||
{
|
||||
unsigned char* md5hex;
|
||||
char* base64;
|
||||
string Signature;
|
||||
std::string Signature;
|
||||
|
||||
if(NULL == (md5hex = s3fs_md5hexsum(fd, 0, -1))){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
if(NULL == (base64 = s3fs_base64(md5hex, get_md5_digest_length()))){
|
||||
return string(""); // ENOMEM
|
||||
return std::string(""); // ENOMEM
|
||||
}
|
||||
delete[] md5hex;
|
||||
|
||||
@ -54,13 +52,13 @@ string s3fs_get_content_md5(int fd)
|
||||
return Signature;
|
||||
}
|
||||
|
||||
string s3fs_md5sum(int fd, off_t start, off_t size)
|
||||
std::string s3fs_md5sum(int fd, off_t start, off_t size)
|
||||
{
|
||||
size_t digestlen = get_md5_digest_length();
|
||||
unsigned char* md5hex;
|
||||
|
||||
if(NULL == (md5hex = s3fs_md5hexsum(fd, start, size))){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
std::string md5 = s3fs_hex(md5hex, digestlen);
|
||||
@ -69,14 +67,14 @@ string s3fs_md5sum(int fd, off_t start, off_t size)
|
||||
return md5;
|
||||
}
|
||||
|
||||
string s3fs_sha256sum(int fd, off_t start, off_t size)
|
||||
std::string s3fs_sha256sum(int fd, off_t start, off_t size)
|
||||
{
|
||||
size_t digestlen = get_sha256_digest_length();
|
||||
char sha256[2 * digestlen + 1];
|
||||
unsigned char* sha256hex;
|
||||
|
||||
if(NULL == (sha256hex = s3fs_sha256hexsum(fd, start, size))){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
memset(sha256, 0, 2 * digestlen + 1);
|
||||
@ -85,7 +83,7 @@ string s3fs_sha256sum(int fd, off_t start, off_t size)
|
||||
}
|
||||
delete[] sha256hex;
|
||||
|
||||
return string(sha256);
|
||||
return std::string(sha256);
|
||||
}
|
||||
|
||||
/*
|
||||
|
384
src/curl.cpp
384
src/curl.cpp
File diff suppressed because it is too large
Load Diff
@ -26,8 +26,6 @@
|
||||
#include "curl_handlerpool.h"
|
||||
#include "autolock.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Class CurlHandlerPool
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include "curl.h"
|
||||
#include "autolock.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Class S3fsMultiCurl
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include "string_util.h"
|
||||
#include "s3fs_auth.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility Functions
|
||||
//-------------------------------------------------------------------
|
||||
@ -43,11 +41,11 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* d
|
||||
if(!data){
|
||||
return list;
|
||||
}
|
||||
string strkey = data;
|
||||
string strval;
|
||||
std::string strkey = data;
|
||||
std::string strval;
|
||||
|
||||
string::size_type pos = strkey.find(':', 0);
|
||||
if(string::npos != pos){
|
||||
std::string::size_type pos = strkey.find(':', 0);
|
||||
if(std::string::npos != pos){
|
||||
strval = strkey.substr(pos + 1);
|
||||
strkey = strkey.substr(0, pos);
|
||||
}
|
||||
@ -69,9 +67,9 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* k
|
||||
}
|
||||
|
||||
// key & value are trimmed and lower (only key)
|
||||
string strkey = trim(string(key));
|
||||
string strval = trim(string(value ? value : ""));
|
||||
string strnew = key + string(": ") + strval;
|
||||
std::string strkey = trim(std::string(key));
|
||||
std::string strval = trim(std::string(value ? value : ""));
|
||||
std::string strnew = key + std::string(": ") + strval;
|
||||
if(NULL == (new_item->data = strdup(strnew.c_str()))){
|
||||
free(new_item);
|
||||
return list;
|
||||
@ -79,9 +77,9 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* k
|
||||
new_item->next = NULL;
|
||||
|
||||
for(lastpos = NULL, curpos = list; curpos; lastpos = curpos, curpos = curpos->next){
|
||||
string strcur = curpos->data;
|
||||
std::string strcur = curpos->data;
|
||||
size_t pos;
|
||||
if(string::npos != (pos = strcur.find(':', 0))){
|
||||
if(std::string::npos != (pos = strcur.find(':', 0))){
|
||||
strcur = strcur.substr(0, pos);
|
||||
}
|
||||
|
||||
@ -122,18 +120,18 @@ struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* k
|
||||
return list;
|
||||
}
|
||||
|
||||
string get_sorted_header_keys(const struct curl_slist* list)
|
||||
std::string get_sorted_header_keys(const struct curl_slist* list)
|
||||
{
|
||||
string sorted_headers;
|
||||
std::string sorted_headers;
|
||||
|
||||
if(!list){
|
||||
return sorted_headers;
|
||||
}
|
||||
|
||||
for( ; list; list = list->next){
|
||||
string strkey = list->data;
|
||||
std::string strkey = list->data;
|
||||
size_t pos;
|
||||
if(string::npos != (pos = strkey.find(':', 0))){
|
||||
if(std::string::npos != (pos = strkey.find(':', 0))){
|
||||
if (trim(strkey.substr(pos + 1)).empty()) {
|
||||
// skip empty-value headers (as they are discarded by libcurl)
|
||||
continue;
|
||||
@ -149,16 +147,16 @@ string get_sorted_header_keys(const struct curl_slist* list)
|
||||
return sorted_headers;
|
||||
}
|
||||
|
||||
string get_header_value(const struct curl_slist* list, const string &key)
|
||||
std::string get_header_value(const struct curl_slist* list, const std::string &key)
|
||||
{
|
||||
if(!list){
|
||||
return "";
|
||||
}
|
||||
|
||||
for( ; list; list = list->next){
|
||||
string strkey = list->data;
|
||||
std::string strkey = list->data;
|
||||
size_t pos;
|
||||
if(string::npos != (pos = strkey.find(':', 0))){
|
||||
if(std::string::npos != (pos = strkey.find(':', 0))){
|
||||
if(0 == strcasecmp(trim(strkey.substr(0, pos)).c_str(), key.c_str())){
|
||||
return trim(strkey.substr(pos+1));
|
||||
}
|
||||
@ -168,9 +166,9 @@ string get_header_value(const struct curl_slist* list, const string &key)
|
||||
return "";
|
||||
}
|
||||
|
||||
string get_canonical_headers(const struct curl_slist* list)
|
||||
std::string get_canonical_headers(const struct curl_slist* list)
|
||||
{
|
||||
string canonical_headers;
|
||||
std::string canonical_headers;
|
||||
|
||||
if(!list){
|
||||
canonical_headers = "\n";
|
||||
@ -178,11 +176,11 @@ string get_canonical_headers(const struct curl_slist* list)
|
||||
}
|
||||
|
||||
for( ; list; list = list->next){
|
||||
string strhead = list->data;
|
||||
std::string strhead = list->data;
|
||||
size_t pos;
|
||||
if(string::npos != (pos = strhead.find(':', 0))){
|
||||
string strkey = trim(lower(strhead.substr(0, pos)));
|
||||
string strval = trim(strhead.substr(pos + 1));
|
||||
if(std::string::npos != (pos = strhead.find(':', 0))){
|
||||
std::string strkey = trim(lower(strhead.substr(0, pos)));
|
||||
std::string strval = trim(strhead.substr(pos + 1));
|
||||
if (strval.empty()) {
|
||||
// skip empty-value headers (as they are discarded by libcurl)
|
||||
continue;
|
||||
@ -197,9 +195,9 @@ string get_canonical_headers(const struct curl_slist* list)
|
||||
return canonical_headers;
|
||||
}
|
||||
|
||||
string get_canonical_headers(const struct curl_slist* list, bool only_amz)
|
||||
std::string get_canonical_headers(const struct curl_slist* list, bool only_amz)
|
||||
{
|
||||
string canonical_headers;
|
||||
std::string canonical_headers;
|
||||
|
||||
if(!list){
|
||||
canonical_headers = "\n";
|
||||
@ -207,11 +205,11 @@ string get_canonical_headers(const struct curl_slist* list, bool only_amz)
|
||||
}
|
||||
|
||||
for( ; list; list = list->next){
|
||||
string strhead = list->data;
|
||||
std::string strhead = list->data;
|
||||
size_t pos;
|
||||
if(string::npos != (pos = strhead.find(':', 0))){
|
||||
string strkey = trim(lower(strhead.substr(0, pos)));
|
||||
string strval = trim(strhead.substr(pos + 1));
|
||||
if(std::string::npos != (pos = strhead.find(':', 0))){
|
||||
std::string strkey = trim(lower(strhead.substr(0, pos)));
|
||||
std::string strval = trim(strhead.substr(pos + 1));
|
||||
if (strval.empty()) {
|
||||
// skip empty-value headers (as they are discarded by libcurl)
|
||||
continue;
|
||||
@ -230,7 +228,7 @@ string get_canonical_headers(const struct curl_slist* list, bool only_amz)
|
||||
}
|
||||
|
||||
// function for using global values
|
||||
bool MakeUrlResource(const char* realpath, string& resourcepath, string& url)
|
||||
bool MakeUrlResource(const char* realpath, std::string& resourcepath, std::string& url)
|
||||
{
|
||||
if(!realpath){
|
||||
return false;
|
||||
@ -240,15 +238,15 @@ bool MakeUrlResource(const char* realpath, string& resourcepath, string& url)
|
||||
return true;
|
||||
}
|
||||
|
||||
string prepare_url(const char* url)
|
||||
std::string prepare_url(const char* url)
|
||||
{
|
||||
S3FS_PRN_INFO3("URL is %s", url);
|
||||
|
||||
string uri;
|
||||
string hostname;
|
||||
string path;
|
||||
string url_str = string(url);
|
||||
string token = string("/") + bucket;
|
||||
std::string uri;
|
||||
std::string hostname;
|
||||
std::string path;
|
||||
std::string url_str = std::string(url);
|
||||
std::string token = std::string("/") + bucket;
|
||||
int bucket_pos;
|
||||
int bucket_length = token.size();
|
||||
int uri_length = 0;
|
||||
@ -266,7 +264,7 @@ string prepare_url(const char* url)
|
||||
path = url_str.substr((bucket_pos + bucket_length));
|
||||
}else{
|
||||
hostname = url_str.substr(uri_length, bucket_pos - uri_length);
|
||||
string part = url_str.substr((bucket_pos + bucket_length));
|
||||
std::string part = url_str.substr((bucket_pos + bucket_length));
|
||||
if('/' != part[0]){
|
||||
part = "/" + part;
|
||||
}
|
||||
@ -284,7 +282,7 @@ string prepare_url(const char* url)
|
||||
// This function uses temporary file, but should not use it.
|
||||
// For not using it, we implement function in each auth file(openssl, nss. gnutls).
|
||||
//
|
||||
bool make_md5_from_binary(const char* pstr, size_t length, string& md5)
|
||||
bool make_md5_from_binary(const char* pstr, size_t length, std::string& md5)
|
||||
{
|
||||
if(!pstr || '\0' == pstr[0]){
|
||||
S3FS_PRN_ERR("Parameter is wrong.");
|
||||
@ -317,12 +315,12 @@ bool make_md5_from_binary(const char* pstr, size_t length, string& md5)
|
||||
return true;
|
||||
}
|
||||
|
||||
string url_to_host(const string &url)
|
||||
std::string url_to_host(const std::string &url)
|
||||
{
|
||||
S3FS_PRN_INFO3("url is %s", url.c_str());
|
||||
|
||||
static const string http = "http://";
|
||||
static const string https = "https://";
|
||||
static const std::string http = "http://";
|
||||
static const std::string https = "https://";
|
||||
std::string hostname;
|
||||
|
||||
if (url.compare(0, http.size(), http) == 0) {
|
||||
@ -335,14 +333,14 @@ string url_to_host(const string &url)
|
||||
}
|
||||
|
||||
size_t idx;
|
||||
if ((idx = hostname.find('/')) != string::npos) {
|
||||
if ((idx = hostname.find('/')) != std::string::npos) {
|
||||
return hostname.substr(0, idx);
|
||||
} else {
|
||||
return hostname;
|
||||
}
|
||||
}
|
||||
|
||||
string get_bucket_host()
|
||||
std::string get_bucket_host()
|
||||
{
|
||||
if(!pathrequeststyle){
|
||||
return bucket + "." + url_to_host(s3host);
|
||||
@ -376,7 +374,7 @@ const char* getCurlDebugHead(curl_infotype type)
|
||||
//
|
||||
// compare ETag ignoring quotes and case
|
||||
//
|
||||
bool etag_equals(string s1, string s2)
|
||||
bool etag_equals(std::string s1, std::string s2)
|
||||
{
|
||||
if(s1.length() > 1 && s1[0] == '\"' && s1[s1.length() - 1] == '\"'){
|
||||
s1 = s1.substr(1, s1.size() - 2);
|
||||
|
@ -32,8 +32,6 @@
|
||||
#include "string_util.h"
|
||||
#include "autolock.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------
|
||||
// Symbols
|
||||
//------------------------------------------------
|
||||
@ -93,7 +91,7 @@ pthread_mutex_t FdManager::fd_manager_lock;
|
||||
pthread_mutex_t FdManager::cache_cleanup_lock;
|
||||
pthread_mutex_t FdManager::reserved_diskspace_lock;
|
||||
bool FdManager::is_lock_init(false);
|
||||
string FdManager::cache_dir;
|
||||
std::string FdManager::cache_dir;
|
||||
bool FdManager::check_cache_dir_exist(false);
|
||||
off_t FdManager::free_disk_space = 0;
|
||||
std::string FdManager::check_cache_output;
|
||||
@ -129,7 +127,7 @@ bool FdManager::DeleteCacheDirectory()
|
||||
return true;
|
||||
}
|
||||
|
||||
string cache_path;
|
||||
std::string cache_path;
|
||||
if(!FdManager::MakeCachePath(NULL, cache_path, false)){
|
||||
return false;
|
||||
}
|
||||
@ -137,7 +135,7 @@ bool FdManager::DeleteCacheDirectory()
|
||||
return false;
|
||||
}
|
||||
|
||||
string mirror_path = FdManager::cache_dir + "/." + bucket + ".mirror";
|
||||
std::string mirror_path = FdManager::cache_dir + "/." + bucket + ".mirror";
|
||||
if(!delete_files_in_dir(mirror_path.c_str(), true)){
|
||||
return false;
|
||||
}
|
||||
@ -155,7 +153,7 @@ int FdManager::DeleteCacheFile(const char* path)
|
||||
if(FdManager::cache_dir.empty()){
|
||||
return 0;
|
||||
}
|
||||
string cache_path;
|
||||
std::string cache_path;
|
||||
if(!FdManager::MakeCachePath(path, cache_path, false)){
|
||||
return 0;
|
||||
}
|
||||
@ -183,14 +181,14 @@ int FdManager::DeleteCacheFile(const char* path)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FdManager::MakeCachePath(const char* path, string& cache_path, bool is_create_dir, bool is_mirror_path)
|
||||
bool FdManager::MakeCachePath(const char* path, std::string& cache_path, bool is_create_dir, bool is_mirror_path)
|
||||
{
|
||||
if(FdManager::cache_dir.empty()){
|
||||
cache_path = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
string resolved_path(FdManager::cache_dir);
|
||||
std::string resolved_path(FdManager::cache_dir);
|
||||
if(!is_mirror_path){
|
||||
resolved_path += "/";
|
||||
resolved_path += bucket;
|
||||
@ -220,12 +218,12 @@ bool FdManager::CheckCacheTopDir()
|
||||
if(FdManager::cache_dir.empty()){
|
||||
return true;
|
||||
}
|
||||
string toppath(FdManager::cache_dir + "/" + bucket);
|
||||
std::string toppath(FdManager::cache_dir + "/" + bucket);
|
||||
|
||||
return check_exist_dir_permission(toppath.c_str());
|
||||
}
|
||||
|
||||
bool FdManager::MakeRandomTempPath(const char* path, string& tmppath)
|
||||
bool FdManager::MakeRandomTempPath(const char* path, std::string& tmppath)
|
||||
{
|
||||
char szBuff[64];
|
||||
|
||||
@ -280,7 +278,7 @@ off_t FdManager::SetEnsureFreeDiskSpace(off_t size)
|
||||
off_t FdManager::GetFreeDiskSpace(const char* path)
|
||||
{
|
||||
struct statvfs vfsbuf;
|
||||
string ctoppath;
|
||||
std::string ctoppath;
|
||||
if(!FdManager::cache_dir.empty()){
|
||||
ctoppath = FdManager::cache_dir + "/";
|
||||
ctoppath = get_exist_directory_path(ctoppath); // existed directory
|
||||
@ -414,7 +412,7 @@ FdEntity* FdManager::GetFdEntity(const char* path, int existfd)
|
||||
}
|
||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||
|
||||
fdent_map_t::iterator iter = fent.find(string(path));
|
||||
fdent_map_t::iterator iter = fent.find(std::string(path));
|
||||
if(fent.end() != iter && (-1 == existfd || (*iter).second->GetFd() == existfd)){
|
||||
iter->second->Dup();
|
||||
return (*iter).second;
|
||||
@ -450,7 +448,7 @@ FdEntity* FdManager::Open(const char* path, headers_t* pmeta, off_t size, time_t
|
||||
AutoLock auto_lock(&FdManager::fd_manager_lock);
|
||||
|
||||
// search in mapping by key(path)
|
||||
fdent_map_t::iterator iter = fent.find(string(path));
|
||||
fdent_map_t::iterator iter = fent.find(std::string(path));
|
||||
|
||||
if(fent.end() == iter && !force_tmpfile && !FdManager::IsCacheDir()){
|
||||
// If the cache directory is not specified, s3fs opens a temporary file
|
||||
@ -477,7 +475,7 @@ FdEntity* FdManager::Open(const char* path, headers_t* pmeta, off_t size, time_t
|
||||
|
||||
}else if(is_create){
|
||||
// not found
|
||||
string cache_path;
|
||||
std::string cache_path;
|
||||
if(!force_tmpfile && !FdManager::MakeCachePath(path, cache_path, true)){
|
||||
S3FS_PRN_ERR("failed to make cache path for object(%s).", path);
|
||||
return NULL;
|
||||
@ -487,7 +485,7 @@ FdEntity* FdManager::Open(const char* path, headers_t* pmeta, off_t size, time_t
|
||||
|
||||
if(!cache_path.empty()){
|
||||
// using cache
|
||||
fent[string(path)] = ent;
|
||||
fent[std::string(path)] = ent;
|
||||
}else{
|
||||
// not using cache, so the key of fdentity is set not really existing path.
|
||||
// (but not strictly unexisting path.)
|
||||
@ -496,7 +494,7 @@ FdEntity* FdManager::Open(const char* path, headers_t* pmeta, off_t size, time_t
|
||||
// The reason why this process here, please look at the definition of the
|
||||
// comments of NOCACHE_PATH_PREFIX_FORM symbol.
|
||||
//
|
||||
string tmppath;
|
||||
std::string tmppath;
|
||||
FdManager::MakeRandomTempPath(path, tmppath);
|
||||
fent[tmppath] = ent;
|
||||
}
|
||||
@ -573,7 +571,7 @@ void FdManager::Rename(const std::string &from, const std::string &to)
|
||||
fent.erase(iter);
|
||||
|
||||
// rename path and caches in fd entity
|
||||
string fentmapkey;
|
||||
std::string fentmapkey;
|
||||
if(!ent->RenamePath(to, fentmapkey)){
|
||||
S3FS_PRN_ERR("Failed to rename FdEntity object for %s to %s", from.c_str(), to.c_str());
|
||||
return;
|
||||
@ -625,7 +623,7 @@ bool FdManager::ChangeEntityToTempPath(FdEntity* ent, const char* path)
|
||||
if((*iter).second == ent){
|
||||
fent.erase(iter++);
|
||||
|
||||
string tmppath;
|
||||
std::string tmppath;
|
||||
FdManager::MakeRandomTempPath(path, tmppath);
|
||||
fent[tmppath] = ent;
|
||||
}else{
|
||||
@ -670,7 +668,7 @@ void FdManager::CleanupCacheDirInternal(const std::string &path)
|
||||
if(0 == strcmp(dent->d_name, "..") || 0 == strcmp(dent->d_name, ".")){
|
||||
continue;
|
||||
}
|
||||
string fullpath = abs_path;
|
||||
std::string fullpath = abs_path;
|
||||
fullpath += "/";
|
||||
fullpath += dent->d_name;
|
||||
struct stat st;
|
||||
@ -679,7 +677,7 @@ void FdManager::CleanupCacheDirInternal(const std::string &path)
|
||||
closedir(dp);
|
||||
return;
|
||||
}
|
||||
string next_path = path + "/" + dent->d_name;
|
||||
std::string next_path = path + "/" + dent->d_name;
|
||||
if(S_ISDIR(st.st_mode)){
|
||||
CleanupCacheDirInternal(next_path);
|
||||
}else{
|
||||
@ -751,7 +749,7 @@ bool FdManager::RawCheckAllCache(FILE* fp, const char* cache_stat_top_dir, const
|
||||
|
||||
// open directory of cache file's stats
|
||||
DIR* statsdir;
|
||||
string target_dir = cache_stat_top_dir;
|
||||
std::string target_dir = cache_stat_top_dir;
|
||||
target_dir += sub_path;
|
||||
if(NULL == (statsdir = opendir(target_dir.c_str()))){
|
||||
S3FS_PRN_ERR("Could not open directory(%s) by errno(%d)", target_dir.c_str(), errno);
|
||||
@ -768,7 +766,7 @@ bool FdManager::RawCheckAllCache(FILE* fp, const char* cache_stat_top_dir, const
|
||||
}
|
||||
|
||||
// reentrant for sub directory
|
||||
string subdir_path = sub_path;
|
||||
std::string subdir_path = sub_path;
|
||||
subdir_path += pdirent->d_name;
|
||||
subdir_path += '/';
|
||||
if(!RawCheckAllCache(fp, cache_stat_top_dir, subdir_path.c_str(), total_file_cnt, err_file_cnt, err_dir_cnt)){
|
||||
@ -782,9 +780,9 @@ bool FdManager::RawCheckAllCache(FILE* fp, const char* cache_stat_top_dir, const
|
||||
++total_file_cnt;
|
||||
|
||||
// make cache file path
|
||||
string strOpenedWarn;
|
||||
string cache_path;
|
||||
string object_file_path = sub_path;
|
||||
std::string strOpenedWarn;
|
||||
std::string cache_path;
|
||||
std::string object_file_path = sub_path;
|
||||
object_file_path += pdirent->d_name;
|
||||
if(!FdManager::MakeCachePath(object_file_path.c_str(), cache_path, false, false) || cache_path.empty()){
|
||||
++err_file_cnt;
|
||||
@ -905,7 +903,7 @@ bool FdManager::CheckAllCache()
|
||||
S3FS_PRN_CACHE(fp, CACHEDBG_FMT_HEAD);
|
||||
|
||||
// Loop in directory of cache file's stats
|
||||
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
std::string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
int total_file_cnt = 0;
|
||||
int err_file_cnt = 0;
|
||||
int err_dir_cnt = 0;
|
||||
|
@ -33,8 +33,6 @@
|
||||
#include "autolock.h"
|
||||
#include "curl.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------
|
||||
// Symbols
|
||||
//------------------------------------------------
|
||||
@ -58,10 +56,10 @@ bool FdEntity::SetNoMixMultipart()
|
||||
int FdEntity::FillFile(int fd, unsigned char byte, off_t size, off_t start)
|
||||
{
|
||||
unsigned char bytes[1024 * 32]; // 32kb
|
||||
memset(bytes, byte, min(static_cast<off_t>(sizeof(bytes)), size));
|
||||
memset(bytes, byte, std::min(static_cast<off_t>(sizeof(bytes)), size));
|
||||
|
||||
for(off_t total = 0, onewrote = 0; total < size; total += onewrote){
|
||||
if(-1 == (onewrote = pwrite(fd, bytes, min(static_cast<off_t>(sizeof(bytes)), size - total), start + total))){
|
||||
if(-1 == (onewrote = pwrite(fd, bytes, std::min(static_cast<off_t>(sizeof(bytes)), size - total), start + total))){
|
||||
S3FS_PRN_ERR("pwrite failed. errno(%d)", errno);
|
||||
return -errno;
|
||||
}
|
||||
@ -263,7 +261,7 @@ int FdEntity::OpenMirrorFile()
|
||||
}
|
||||
|
||||
// make temporary directory
|
||||
string bupdir;
|
||||
std::string bupdir;
|
||||
if(!FdManager::MakeCachePath(NULL, bupdir, true, true)){
|
||||
S3FS_PRN_ERR("could not make bup cache directory path or create it.");
|
||||
return -EIO;
|
||||
@ -587,13 +585,13 @@ bool FdEntity::OpenAndLoadAll(headers_t* pmeta, off_t* size, bool force_load)
|
||||
// The mirror file descriptor is also the same. The mirror file path does
|
||||
// not need to be changed and will remain as it is.
|
||||
//
|
||||
bool FdEntity::RenamePath(const string& newpath, string& fentmapkey)
|
||||
bool FdEntity::RenamePath(const std::string& newpath, std::string& fentmapkey)
|
||||
{
|
||||
if(!cachepath.empty()){
|
||||
// has cache path
|
||||
|
||||
// make new cache path
|
||||
string newcachepath;
|
||||
std::string newcachepath;
|
||||
if(!FdManager::MakeCachePath(newpath.c_str(), newcachepath, true)){
|
||||
S3FS_PRN_ERR("failed to make cache path for object(%s).", newpath.c_str());
|
||||
return false;
|
||||
@ -729,7 +727,7 @@ bool FdEntity::GetSize(off_t& size)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FdEntity::GetXattr(string& xattr)
|
||||
bool FdEntity::GetXattr(std::string& xattr)
|
||||
{
|
||||
AutoLock auto_lock(&fdent_lock);
|
||||
|
||||
@ -775,7 +773,7 @@ bool FdEntity::SetContentType(const char* path)
|
||||
return false;
|
||||
}
|
||||
AutoLock auto_lock(&fdent_lock);
|
||||
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(string(path));
|
||||
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(path));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -912,7 +910,7 @@ int FdEntity::NoCacheLoadAndPost(off_t start, off_t size)
|
||||
for(off_t oneread = 0, totalread = (iter->offset < start ? start : 0); totalread < static_cast<off_t>(iter->bytes); totalread += oneread){
|
||||
int upload_fd = fd;
|
||||
off_t offset = iter->offset + totalread;
|
||||
oneread = min(static_cast<off_t>(iter->bytes) - totalread, S3fsCurl::GetMultipartSize());
|
||||
oneread = std::min(static_cast<off_t>(iter->bytes) - totalread, S3fsCurl::GetMultipartSize());
|
||||
|
||||
// check rest size is over minimum part size
|
||||
//
|
||||
@ -1301,7 +1299,7 @@ ssize_t FdEntity::Read(char* bytes, off_t start, size_t size, bool force_load)
|
||||
// load size(for prefetch)
|
||||
size_t load_size = size;
|
||||
if(start + static_cast<ssize_t>(size) < pagelist.Size()){
|
||||
ssize_t prefetch_max_size = max(static_cast<off_t>(size), S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount());
|
||||
ssize_t prefetch_max_size = std::max(static_cast<off_t>(size), S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount());
|
||||
|
||||
if(start + prefetch_max_size < pagelist.Size()){
|
||||
load_size = prefetch_max_size;
|
||||
|
@ -29,8 +29,6 @@
|
||||
#include "fdcache_page.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------
|
||||
// Symbols
|
||||
//------------------------------------------------
|
||||
@ -566,8 +564,8 @@ int PageList::GetUnloadedPages(fdpage_list_t& unloaded_list, off_t start, off_t
|
||||
}
|
||||
|
||||
// page area
|
||||
off_t page_start = max(iter->offset, start);
|
||||
off_t page_next = min(iter->next(), next);
|
||||
off_t page_start = std::max(iter->offset, start);
|
||||
off_t page_next = std::min(iter->next(), next);
|
||||
off_t page_size = page_next - page_start;
|
||||
|
||||
// add list
|
||||
@ -720,7 +718,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
|
||||
//
|
||||
// put to file
|
||||
//
|
||||
ostringstream ssall;
|
||||
std::ostringstream ssall;
|
||||
ssall << inode << ":" << Size();
|
||||
|
||||
for(fdpage_list_t::iterator iter = pages.begin(); iter != pages.end(); ++iter){
|
||||
@ -731,7 +729,7 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
|
||||
S3FS_PRN_ERR("failed to truncate file(to 0) for stats(%d)", errno);
|
||||
return false;
|
||||
}
|
||||
string strall = ssall.str();
|
||||
std::string strall = ssall.str();
|
||||
if(0 >= pwrite(file.GetFd(), strall.c_str(), strall.length(), 0)){
|
||||
S3FS_PRN_ERR("failed to write stats(%d)", errno);
|
||||
return false;
|
||||
@ -760,8 +758,8 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
|
||||
delete[] ptmp;
|
||||
return false;
|
||||
}
|
||||
string oneline;
|
||||
istringstream ssall(ptmp);
|
||||
std::string oneline;
|
||||
std::istringstream ssall(ptmp);
|
||||
|
||||
// loaded
|
||||
Clear();
|
||||
@ -774,9 +772,9 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
|
||||
delete[] ptmp;
|
||||
return false;
|
||||
}else{
|
||||
istringstream sshead(oneline);
|
||||
string strhead1;
|
||||
string strhead2;
|
||||
std::istringstream sshead(oneline);
|
||||
std::string strhead1;
|
||||
std::string strhead2;
|
||||
|
||||
// get first part in head line.
|
||||
if(!getline(sshead, strhead1, ':')){
|
||||
@ -810,8 +808,8 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
|
||||
// load each part
|
||||
bool is_err = false;
|
||||
while(getline(ssall, oneline, '\n')){
|
||||
string part;
|
||||
istringstream ssparts(oneline);
|
||||
std::string part;
|
||||
std::istringstream ssparts(oneline);
|
||||
// offset
|
||||
if(!getline(ssparts, part, ':')){
|
||||
is_err = true;
|
||||
|
@ -31,14 +31,12 @@
|
||||
#include "s3fs_util.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//------------------------------------------------
|
||||
// CacheFileStat class methods
|
||||
//------------------------------------------------
|
||||
string CacheFileStat::GetCacheFileStatTopDir()
|
||||
std::string CacheFileStat::GetCacheFileStatTopDir()
|
||||
{
|
||||
string top_path("");
|
||||
std::string top_path("");
|
||||
if(!FdManager::IsCacheDir() || bucket.empty()){
|
||||
return top_path;
|
||||
}
|
||||
@ -51,9 +49,9 @@ string CacheFileStat::GetCacheFileStatTopDir()
|
||||
return top_path;
|
||||
}
|
||||
|
||||
bool CacheFileStat::MakeCacheFileStatPath(const char* path, string& sfile_path, bool is_create_dir)
|
||||
bool CacheFileStat::MakeCacheFileStatPath(const char* path, std::string& sfile_path, bool is_create_dir)
|
||||
{
|
||||
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
std::string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
if(top_path.empty()){
|
||||
S3FS_PRN_ERR("The path to cache top dir is empty.");
|
||||
return false;
|
||||
@ -76,7 +74,7 @@ bool CacheFileStat::MakeCacheFileStatPath(const char* path, string& sfile_path,
|
||||
|
||||
bool CacheFileStat::CheckCacheFileStatTopDir()
|
||||
{
|
||||
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
std::string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
if(top_path.empty()){
|
||||
S3FS_PRN_INFO("The path to cache top dir is empty, thus not need to check permission.");
|
||||
return true;
|
||||
@ -91,7 +89,7 @@ bool CacheFileStat::DeleteCacheFileStat(const char* path)
|
||||
return false;
|
||||
}
|
||||
// stat path
|
||||
string sfile_path;
|
||||
std::string sfile_path;
|
||||
if(!CacheFileStat::MakeCacheFileStatPath(path, sfile_path, false)){
|
||||
S3FS_PRN_ERR("failed to create cache stat file path(%s)", path);
|
||||
return false;
|
||||
@ -113,7 +111,7 @@ bool CacheFileStat::DeleteCacheFileStat(const char* path)
|
||||
//
|
||||
bool CacheFileStat::DeleteCacheFileStatDirectory()
|
||||
{
|
||||
string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
std::string top_path = CacheFileStat::GetCacheFileStatTopDir();
|
||||
if(top_path.empty()){
|
||||
S3FS_PRN_INFO("The path to cache top dir is empty, thus not need to remove it.");
|
||||
return true;
|
||||
@ -128,8 +126,8 @@ bool CacheFileStat::RenameCacheFileStat(const char* oldpath, const char* newpath
|
||||
}
|
||||
|
||||
// stat path
|
||||
string old_filestat;
|
||||
string new_filestat;
|
||||
std::string old_filestat;
|
||||
std::string new_filestat;
|
||||
if(!CacheFileStat::MakeCacheFileStatPath(oldpath, old_filestat, false) || !CacheFileStat::MakeCacheFileStatPath(newpath, new_filestat, false)){
|
||||
return false;
|
||||
}
|
||||
@ -203,7 +201,7 @@ bool CacheFileStat::RawOpen(bool readonly)
|
||||
return true;
|
||||
}
|
||||
// stat path
|
||||
string sfile_path;
|
||||
std::string sfile_path;
|
||||
if(!CacheFileStat::MakeCacheFileStatPath(path.c_str(), sfile_path, true)){
|
||||
S3FS_PRN_ERR("failed to create cache stat file path(%s)", path.c_str());
|
||||
return false;
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "s3fs_auth.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility Function for version
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include "metaheader.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility functions for convert
|
||||
//-------------------------------------------------------------------
|
||||
@ -41,11 +39,11 @@ time_t get_mtime(const char *str)
|
||||
// truncating the floating point or less (in seconds or less) to
|
||||
// correspond to this.
|
||||
//
|
||||
string strmtime;
|
||||
std::string strmtime;
|
||||
if(str && '\0' != *str){
|
||||
strmtime = str;
|
||||
string::size_type pos = strmtime.find('.', 0);
|
||||
if(string::npos != pos){
|
||||
std::string::size_type pos = strmtime.find('.', 0);
|
||||
if(std::string::npos != pos){
|
||||
strmtime = strmtime.substr(0, pos);
|
||||
}
|
||||
}
|
||||
@ -137,10 +135,10 @@ mode_t get_mode(const headers_t& meta, const char* path, bool checkdir, bool for
|
||||
mode |= S_IFDIR;
|
||||
}else{
|
||||
if(meta.end() != (iter = meta.find("Content-Type"))){
|
||||
string strConType = (*iter).second;
|
||||
std::string strConType = (*iter).second;
|
||||
// Leave just the mime type, remove any optional parameters (eg charset)
|
||||
string::size_type pos = strConType.find(';');
|
||||
if(string::npos != pos){
|
||||
std::string::size_type pos = strConType.find(';');
|
||||
if(std::string::npos != pos){
|
||||
strConType = strConType.substr(0, pos);
|
||||
}
|
||||
if(strConType == "application/x-directory" || strConType == "httpd/unix-directory"){
|
||||
|
@ -29,8 +29,6 @@
|
||||
#include "s3fs_auth.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Global variables
|
||||
//-------------------------------------------------------------------
|
||||
@ -74,7 +72,7 @@ static bool abort_incomp_mpu_list(incomp_mpu_list_t& list, time_t abort_time)
|
||||
bool result = true;
|
||||
for(incomp_mpu_list_t::iterator iter = list.begin(); iter != list.end(); ++iter){
|
||||
const char* tpath = (*iter).key.c_str();
|
||||
string upload_id = (*iter).id;
|
||||
std::string upload_id = (*iter).id;
|
||||
|
||||
if(0 != abort_time){ // abort_time is 0, it means all.
|
||||
time_t date = 0;
|
||||
@ -108,8 +106,8 @@ int s3fs_utility_processing(time_t abort_time)
|
||||
printf("\n*** s3fs run as utility mode.\n\n");
|
||||
|
||||
S3fsCurl s3fscurl;
|
||||
string body;
|
||||
int result = EXIT_SUCCESS;
|
||||
std::string body;
|
||||
int result = EXIT_SUCCESS;
|
||||
if(0 != s3fscurl.MultipartListRequest(body)){
|
||||
S3FS_PRN_EXIT("Could not get list multipart upload.\nThere is no incomplete multipart uploaded object in bucket.\n");
|
||||
result = EXIT_FAILURE;
|
||||
|
@ -38,8 +38,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "s3fs_auth.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility Function for version
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "s3fs_auth.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Utility Function for version
|
||||
//-------------------------------------------------------------------
|
||||
|
302
src/s3fs.cpp
302
src/s3fs.cpp
@ -46,8 +46,6 @@
|
||||
#include "s3fs_help.h"
|
||||
#include "mpu_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Symbols
|
||||
//-------------------------------------------------------------------
|
||||
@ -112,8 +110,8 @@ int put_headers(const char* path, headers_t& meta, bool is_copy); // [NOTE
|
||||
// Static functions : prototype
|
||||
//-------------------------------------------------------------------
|
||||
static bool is_special_name_folder_object(const char* path);
|
||||
static int chk_dir_object_type(const char* path, string& newpath, string& nowpath, string& nowcache, headers_t* pmeta = NULL, dirtype* pDirType = NULL);
|
||||
static int remove_old_type_dir(const string& path, dirtype type);
|
||||
static int chk_dir_object_type(const char* path, std::string& newpath, std::string& nowpath, std::string& nowcache, headers_t* pmeta = NULL, dirtype* pDirType = NULL);
|
||||
static int remove_old_type_dir(const std::string& path, dirtype type);
|
||||
static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t* pmeta = NULL, bool overcheck = true, bool* pisforce = NULL, bool add_no_truncate_cache = false);
|
||||
static int check_object_access(const char* path, int mask, struct stat* pstbuf);
|
||||
static int check_object_owner(const char* path, struct stat* pstbuf);
|
||||
@ -133,7 +131,7 @@ static int clone_directory_object(const char* from, const char* to);
|
||||
static int rename_directory(const char* from, const char* to);
|
||||
static int remote_mountpath_exists(const char* path);
|
||||
static void free_xattrs(xattrs_t& xattrs);
|
||||
static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTRVAL& pval);
|
||||
static bool parse_xattr_keyval(const std::string& xattrpair, std::string& key, PXATTRVAL& pval);
|
||||
static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs);
|
||||
static std::string build_xattrs(const xattrs_t& xattrs);
|
||||
static int s3fs_check_service();
|
||||
@ -214,10 +212,10 @@ static bool is_special_name_folder_object(const char* path)
|
||||
return false;
|
||||
}
|
||||
|
||||
string strpath = path;
|
||||
std::string strpath = path;
|
||||
headers_t header;
|
||||
|
||||
if(string::npos == strpath.find("_$folder$", 0)){
|
||||
if(std::string::npos == strpath.find("_$folder$", 0)){
|
||||
if('/' == strpath[strpath.length() - 1]){
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
}
|
||||
@ -244,7 +242,7 @@ static bool is_special_name_folder_object(const char* path)
|
||||
// pmeta: headers map
|
||||
// pDirType: directory object type
|
||||
//
|
||||
static int chk_dir_object_type(const char* path, string& newpath, string& nowpath, string& nowcache, headers_t* pmeta, dirtype* pDirType)
|
||||
static int chk_dir_object_type(const char* path, std::string& newpath, std::string& nowpath, std::string& nowcache, headers_t* pmeta, dirtype* pDirType)
|
||||
{
|
||||
dirtype TypeTmp;
|
||||
int result = -1;
|
||||
@ -254,8 +252,8 @@ static int chk_dir_object_type(const char* path, string& newpath, string& nowpat
|
||||
// Normalize new path.
|
||||
newpath = path;
|
||||
if('/' != newpath[newpath.length() - 1]){
|
||||
string::size_type Pos;
|
||||
if(string::npos != (Pos = newpath.find("_$folder$", 0))){
|
||||
std::string::size_type Pos;
|
||||
if(std::string::npos != (Pos = newpath.find("_$folder$", 0))){
|
||||
newpath = newpath.substr(0, Pos);
|
||||
}
|
||||
newpath += "/";
|
||||
@ -322,7 +320,7 @@ static int chk_dir_object_type(const char* path, string& newpath, string& nowpat
|
||||
return result;
|
||||
}
|
||||
|
||||
static int remove_old_type_dir(const string& path, dirtype type)
|
||||
static int remove_old_type_dir(const std::string& path, dirtype type)
|
||||
{
|
||||
if(IS_RMTYPEDIR(type)){
|
||||
S3fsCurl s3fscurl;
|
||||
@ -354,10 +352,10 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
struct stat* pstat = pstbuf ? pstbuf : &tmpstbuf;
|
||||
headers_t tmpHead;
|
||||
headers_t* pheader = pmeta ? pmeta : &tmpHead;
|
||||
string strpath;
|
||||
std::string strpath;
|
||||
S3fsCurl s3fscurl;
|
||||
bool forcedir = false;
|
||||
string::size_type Pos;
|
||||
std::string::size_type Pos;
|
||||
|
||||
S3FS_PRN_DBG("[path=%s]", path);
|
||||
|
||||
@ -378,7 +376,7 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
pisforce = (NULL != pisforce ? pisforce : &forcedir);
|
||||
(*pisforce) = false;
|
||||
strpath = path;
|
||||
if(support_compat_dir && overcheck && string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
if(support_compat_dir && overcheck && std::string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
strpath = strpath.substr(0, Pos);
|
||||
strpath += "/";
|
||||
}
|
||||
@ -400,7 +398,7 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
if(0 != result){
|
||||
if(overcheck){
|
||||
// when support_compat_dir is disabled, strpath maybe have "_$folder$".
|
||||
if('/' != strpath[strpath.length() - 1] && string::npos == strpath.find("_$folder$", 0)){
|
||||
if('/' != strpath[strpath.length() - 1] && std::string::npos == strpath.find("_$folder$", 0)){
|
||||
// now path is "object", do check "object/" for over checking
|
||||
strpath += "/";
|
||||
result = s3fscurl.HeadRequest(strpath.c_str(), (*pheader));
|
||||
@ -415,13 +413,13 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
|
||||
if(0 != result){
|
||||
// cut "_$folder$" for over checking "no dir object" after here
|
||||
if(string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
if(std::string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
strpath = strpath.substr(0, Pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(support_compat_dir && 0 != result && string::npos == strpath.find("_$folder$", 0)){
|
||||
if(support_compat_dir && 0 != result && std::string::npos == strpath.find("_$folder$", 0)){
|
||||
// now path is "object" or "object/", do check "no dir object" which is not object but has only children.
|
||||
if('/' == strpath[strpath.length() - 1]){
|
||||
strpath = strpath.substr(0, strpath.length() - 1);
|
||||
@ -434,7 +432,7 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(support_compat_dir && '/' != strpath[strpath.length() - 1] && string::npos == strpath.find("_$folder$", 0) && is_need_check_obj_detail(*pheader)){
|
||||
if(support_compat_dir && '/' != strpath[strpath.length() - 1] && std::string::npos == strpath.find("_$folder$", 0) && is_need_check_obj_detail(*pheader)){
|
||||
// check a case of that "object" does not have attribute and "object" is possible to be directory.
|
||||
if(-ENOTEMPTY == directory_empty(strpath.c_str())){
|
||||
// found "no dir object".
|
||||
@ -453,7 +451,7 @@ static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t
|
||||
}
|
||||
|
||||
// if path has "_$folder$", need to cut it.
|
||||
if(string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
if(std::string::npos != (Pos = strpath.find("_$folder$", 0))){
|
||||
strpath = strpath.substr(0, Pos);
|
||||
strpath += "/";
|
||||
}
|
||||
@ -609,7 +607,7 @@ static int check_object_owner(const char* path, struct stat* pstbuf)
|
||||
//
|
||||
static int check_parent_object_access(const char* path, int mask)
|
||||
{
|
||||
string parent;
|
||||
std::string parent;
|
||||
int result;
|
||||
|
||||
S3FS_PRN_DBG("[path=%s]", path);
|
||||
@ -647,7 +645,7 @@ static int check_parent_object_access(const char* path, int mask)
|
||||
//
|
||||
// ssevalue is MD5 for SSE-C type, or KMS id for SSE-KMS
|
||||
//
|
||||
bool get_object_sse_type(const char* path, sse_type_t& ssetype, string& ssevalue)
|
||||
bool get_object_sse_type(const char* path, sse_type_t& ssetype, std::string& ssevalue)
|
||||
{
|
||||
if(!path){
|
||||
return false;
|
||||
@ -662,7 +660,7 @@ bool get_object_sse_type(const char* path, sse_type_t& ssetype, string& ssevalue
|
||||
ssetype = sse_type_t::SSE_DISABLE;
|
||||
ssevalue.erase();
|
||||
for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){
|
||||
string key = (*iter).first;
|
||||
std::string key = (*iter).first;
|
||||
if(0 == strcasecmp(key.c_str(), "x-amz-server-side-encryption") && 0 == strcasecmp((*iter).second.c_str(), "AES256")){
|
||||
ssetype = sse_type_t::SSE_S3;
|
||||
}else if(0 == strcasecmp(key.c_str(), "x-amz-server-side-encryption-aws-kms-key-id")){
|
||||
@ -800,10 +798,10 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
|
||||
return 0;
|
||||
}
|
||||
WTF8_ENCODE(path)
|
||||
string strValue;
|
||||
std::string strValue;
|
||||
|
||||
// check symblic link cache
|
||||
if(!StatCache::getStatCacheData()->GetSymlink(string(path), strValue)){
|
||||
if(!StatCache::getStatCacheData()->GetSymlink(std::string(path), strValue)){
|
||||
// not found in cache, then open the path
|
||||
FdEntity* ent;
|
||||
if(NULL == (ent = get_local_fent(path))){
|
||||
@ -833,7 +831,7 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
|
||||
FdManager::get()->Close(ent);
|
||||
|
||||
// check buf if it has space words.
|
||||
strValue = trim(string(buf));
|
||||
strValue = trim(std::string(buf));
|
||||
|
||||
// decode wtf8. This will always be shorter
|
||||
if(use_wtf8){
|
||||
@ -841,7 +839,7 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
|
||||
}
|
||||
|
||||
// add symblic link cache
|
||||
if(!StatCache::getStatCacheData()->AddSymlink(string(path), strValue)){
|
||||
if(!StatCache::getStatCacheData()->AddSymlink(std::string(path), strValue)){
|
||||
S3FS_PRN_ERR("failed to add symbolic link cache for %s", path);
|
||||
}
|
||||
}
|
||||
@ -910,7 +908,7 @@ static int create_file_object(const char* path, mode_t mode, uid_t uid, gid_t gi
|
||||
|
||||
time_t now = time(NULL);
|
||||
headers_t meta;
|
||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(string(path));
|
||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(path));
|
||||
meta["x-amz-meta-uid"] = str(uid);
|
||||
meta["x-amz-meta-gid"] = str(gid);
|
||||
meta["x-amz-meta-mode"] = str(mode);
|
||||
@ -993,7 +991,7 @@ static int create_directory_object(const char* path, mode_t mode, time_t time, u
|
||||
if(!path || '\0' == path[0]){
|
||||
return -1;
|
||||
}
|
||||
string tpath = path;
|
||||
std::string tpath = path;
|
||||
if('/' != tpath[tpath.length() - 1]){
|
||||
tpath += "/";
|
||||
}
|
||||
@ -1078,7 +1076,7 @@ static int s3fs_rmdir(const char* _path)
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
std::string strpath;
|
||||
struct stat stbuf;
|
||||
|
||||
S3FS_PRN_INFO("[path=%s]", path);
|
||||
@ -1155,7 +1153,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
||||
|
||||
time_t now = time(NULL);
|
||||
headers_t headers;
|
||||
headers["Content-Type"] = string("application/octet-stream"); // Static
|
||||
headers["Content-Type"] = std::string("application/octet-stream"); // Static
|
||||
headers["x-amz-meta-mode"] = str(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
headers["x-amz-meta-ctime"] = str(now);
|
||||
headers["x-amz-meta-mtime"] = str(now);
|
||||
@ -1169,7 +1167,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
||||
return -errno;
|
||||
}
|
||||
// write(without space words)
|
||||
string strFrom = trim(string(from));
|
||||
std::string strFrom = trim(std::string(from));
|
||||
ssize_t from_size = static_cast<ssize_t>(strFrom.length());
|
||||
if(from_size != ent->Write(strFrom.c_str(), 0, from_size)){
|
||||
S3FS_PRN_ERR("could not write tmpfile(errno=%d)", errno);
|
||||
@ -1183,7 +1181,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
||||
FdManager::get()->Close(ent);
|
||||
|
||||
StatCache::getStatCacheData()->DelStat(to);
|
||||
if(!StatCache::getStatCacheData()->AddSymlink(string(to), strFrom)){
|
||||
if(!StatCache::getStatCacheData()->AddSymlink(std::string(to), strFrom)){
|
||||
S3FS_PRN_ERR("failed to add symbolic link cache for %s", to);
|
||||
}
|
||||
S3FS_MALLOCTRIM(0);
|
||||
@ -1194,7 +1192,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
|
||||
static int rename_object(const char* from, const char* to)
|
||||
{
|
||||
int result;
|
||||
string s3_realpath;
|
||||
std::string s3_realpath;
|
||||
headers_t meta;
|
||||
|
||||
S3FS_PRN_INFO1("[from=%s][to=%s]", from , to);
|
||||
@ -1213,7 +1211,7 @@ static int rename_object(const char* from, const char* to)
|
||||
s3_realpath = get_realpath(from);
|
||||
|
||||
meta["x-amz-copy-source"] = urlEncode(service_path + bucket + s3_realpath);
|
||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(string(to));
|
||||
meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(to));
|
||||
meta["x-amz-metadata-directive"] = "REPLACE";
|
||||
|
||||
if(0 != (result = put_headers(to, meta, true))){
|
||||
@ -1335,11 +1333,11 @@ static int rename_directory(const char* from, const char* to)
|
||||
{
|
||||
S3ObjList head;
|
||||
s3obj_list_t headlist;
|
||||
string strfrom = from ? from : ""; // from is without "/".
|
||||
string strto = to ? to : ""; // to is without "/" too.
|
||||
string basepath = strfrom + "/";
|
||||
string newpath; // should be from name(not used)
|
||||
string nowcache; // now cache path(not used)
|
||||
std::string strfrom = from ? from : ""; // from is without "/".
|
||||
std::string strto = to ? to : ""; // to is without "/" too.
|
||||
std::string basepath = strfrom + "/";
|
||||
std::string newpath; // should be from name(not used)
|
||||
std::string nowcache; // now cache path(not used)
|
||||
dirtype DirType;
|
||||
bool normdir;
|
||||
MVNODE* mn_head = NULL;
|
||||
@ -1384,9 +1382,9 @@ static int rename_directory(const char* from, const char* to)
|
||||
s3obj_list_t::const_iterator liter;
|
||||
for(liter = headlist.begin(); headlist.end() != liter; ++liter){
|
||||
// make "from" and "to" object name.
|
||||
string from_name = basepath + (*liter);
|
||||
string to_name = strto + (*liter);
|
||||
string etag = head.GetETag((*liter).c_str());
|
||||
std::string from_name = basepath + (*liter);
|
||||
std::string to_name = strto + (*liter);
|
||||
std::string etag = head.GetETag((*liter).c_str());
|
||||
|
||||
// Check subdirectory.
|
||||
StatCache::getStatCacheData()->HasStat(from_name, etag.c_str()); // Check ETag
|
||||
@ -1531,9 +1529,9 @@ static int s3fs_chmod(const char* _path, mode_t mode)
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
headers_t meta;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
@ -1625,9 +1623,9 @@ static int s3fs_chmod_nocopy(const char* _path, mode_t mode)
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
|
||||
@ -1704,9 +1702,9 @@ static int s3fs_chown(const char* _path, uid_t uid, gid_t gid)
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
headers_t meta;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
@ -1804,9 +1802,9 @@ static int s3fs_chown_nocopy(const char* _path, uid_t uid, gid_t gid)
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
|
||||
@ -1891,9 +1889,9 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2])
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
headers_t meta;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
@ -1985,9 +1983,9 @@ static int s3fs_utimens_nocopy(const char* _path, const struct timespec ts[2])
|
||||
{
|
||||
WTF8_ENCODE(path)
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
|
||||
@ -2105,7 +2103,7 @@ static int s3fs_truncate(const char* _path, off_t size)
|
||||
return -EIO;
|
||||
}
|
||||
time_t now = time(NULL);
|
||||
meta["Content-Type"] = string("application/octet-stream"); // Static
|
||||
meta["Content-Type"] = std::string("application/octet-stream"); // Static
|
||||
meta["x-amz-meta-mode"] = str(S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
meta["x-amz-meta-ctime"] = str(now);
|
||||
meta["x-amz-meta-mtime"] = str(now);
|
||||
@ -2331,7 +2329,7 @@ static int s3fs_release(const char* _path, struct fuse_file_info* fi)
|
||||
// [NOTE]
|
||||
// All opened file's stats is cached with no truncate flag.
|
||||
// Thus we unset it here.
|
||||
StatCache::getStatCacheData()->ChangeNoTruncateFlag(string(path), false);
|
||||
StatCache::getStatCacheData()->ChangeNoTruncateFlag(std::string(path), false);
|
||||
|
||||
// [NOTICE]
|
||||
// At first, we remove stats cache.
|
||||
@ -2388,7 +2386,7 @@ static bool multi_head_callback(S3fsCurl* s3fscurl)
|
||||
if(!s3fscurl){
|
||||
return false;
|
||||
}
|
||||
string saved_path = s3fscurl->GetSpacialSavedPath();
|
||||
std::string saved_path = s3fscurl->GetSpacialSavedPath();
|
||||
if(!StatCache::getStatCacheData()->AddStat(saved_path, *(s3fscurl->GetResponseHeaders()))){
|
||||
S3FS_PRN_ERR("failed adding stat cache [path=%s]", saved_path.c_str());
|
||||
return false;
|
||||
@ -2417,9 +2415,9 @@ static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl)
|
||||
}
|
||||
|
||||
S3fsCurl* newcurl = new S3fsCurl(s3fscurl->IsUseAhbe());
|
||||
string path = s3fscurl->GetPath();
|
||||
string base_path = s3fscurl->GetBasePath();
|
||||
string saved_path = s3fscurl->GetSpacialSavedPath();
|
||||
std::string path = s3fscurl->GetPath();
|
||||
std::string base_path = s3fscurl->GetBasePath();
|
||||
std::string saved_path = s3fscurl->GetSpacialSavedPath();
|
||||
|
||||
if(!newcurl->PreHeadRequest(path, base_path, saved_path, ssec_key_pos)){
|
||||
S3FS_PRN_ERR("Could not duplicate curl object(%s).", saved_path.c_str());
|
||||
@ -2452,10 +2450,10 @@ static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf
|
||||
fillerlist.clear();
|
||||
// Make single head request(with max).
|
||||
for(iter = headlist.begin(); headlist.end() != iter; iter = headlist.erase(iter)){
|
||||
string disppath = path + (*iter);
|
||||
string etag = head.GetETag((*iter).c_str());
|
||||
std::string disppath = path + (*iter);
|
||||
std::string etag = head.GetETag((*iter).c_str());
|
||||
|
||||
string fillpath = disppath;
|
||||
std::string fillpath = disppath;
|
||||
if('/' == disppath[disppath.length() - 1]){
|
||||
fillpath = fillpath.substr(0, fillpath.length() -1);
|
||||
}
|
||||
@ -2501,7 +2499,7 @@ static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf
|
||||
for(iter = fillerlist.begin(); fillerlist.end() != iter; ++iter){
|
||||
struct stat st;
|
||||
bool in_cache = StatCache::getStatCacheData()->GetStat((*iter), &st);
|
||||
string bpath = mybasename((*iter));
|
||||
std::string bpath = mybasename((*iter));
|
||||
if(use_wtf8){
|
||||
bpath = s3fs_wtf8_decode(bpath);
|
||||
}
|
||||
@ -2542,7 +2540,7 @@ static int s3fs_readdir(const char* _path, void* buf, fuse_fill_dir_t filler, of
|
||||
}
|
||||
|
||||
// Send multi head request for stats caching.
|
||||
string strpath = path;
|
||||
std::string strpath = path;
|
||||
if(strcmp(path, "/") != 0){
|
||||
strpath += "/";
|
||||
}
|
||||
@ -2556,12 +2554,12 @@ static int s3fs_readdir(const char* _path, void* buf, fuse_fill_dir_t filler, of
|
||||
|
||||
static int list_bucket(const char* path, S3ObjList& head, const char* delimiter, bool check_content_only)
|
||||
{
|
||||
string s3_realpath;
|
||||
string query_delimiter;;
|
||||
string query_prefix;;
|
||||
string query_maxkey;;
|
||||
string next_marker;
|
||||
bool truncated = true;
|
||||
std::string s3_realpath;
|
||||
std::string query_delimiter;
|
||||
std::string query_prefix;
|
||||
std::string query_maxkey;
|
||||
std::string next_marker;
|
||||
bool truncated = true;
|
||||
S3fsCurl s3fscurl;
|
||||
xmlDocPtr doc;
|
||||
|
||||
@ -2590,7 +2588,7 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter,
|
||||
}
|
||||
|
||||
while(truncated){
|
||||
string each_query = query_delimiter;
|
||||
std::string each_query = query_delimiter;
|
||||
if(!next_marker.empty()){
|
||||
each_query += "marker=" + urlEncode(next_marker) + "&";
|
||||
next_marker = "";
|
||||
@ -2625,7 +2623,7 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter,
|
||||
// If did not specify "delimiter", s3 did not return "NextMarker".
|
||||
// On this case, can use last name for next marker.
|
||||
//
|
||||
string lastname;
|
||||
std::string lastname;
|
||||
if(!head.GetLastName(lastname)){
|
||||
S3FS_PRN_WARN("Could not find next marker, thus break loop.");
|
||||
truncated = false;
|
||||
@ -2677,12 +2675,12 @@ static void free_xattrs(xattrs_t& xattrs)
|
||||
xattrs.clear();
|
||||
}
|
||||
|
||||
static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTRVAL& pval)
|
||||
static bool parse_xattr_keyval(const std::string& xattrpair, std::string& key, PXATTRVAL& pval)
|
||||
{
|
||||
// parse key and value
|
||||
size_t pos;
|
||||
string tmpval;
|
||||
if(string::npos == (pos = xattrpair.find_first_of(':'))){
|
||||
std::string tmpval;
|
||||
if(std::string::npos == (pos = xattrpair.find_first_of(':'))){
|
||||
S3FS_PRN_ERR("one of xattr pair(%s) is wrong format.", xattrpair.c_str());
|
||||
return false;
|
||||
}
|
||||
@ -2706,17 +2704,17 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
||||
xattrs.clear();
|
||||
|
||||
// decode
|
||||
string jsonxattrs = urlDecode(strxattrs);
|
||||
std::string jsonxattrs = urlDecode(strxattrs);
|
||||
|
||||
// get from "{" to "}"
|
||||
string restxattrs;
|
||||
std::string restxattrs;
|
||||
{
|
||||
size_t startpos;
|
||||
size_t endpos = string::npos;
|
||||
if(string::npos != (startpos = jsonxattrs.find_first_of('{'))){
|
||||
size_t endpos = std::string::npos;
|
||||
if(std::string::npos != (startpos = jsonxattrs.find_first_of('{'))){
|
||||
endpos = jsonxattrs.find_last_of('}');
|
||||
}
|
||||
if(startpos == string::npos || endpos == string::npos || endpos <= startpos){
|
||||
if(startpos == std::string::npos || endpos == std::string::npos || endpos <= startpos){
|
||||
S3FS_PRN_WARN("xattr header(%s) is not json format.", jsonxattrs.c_str());
|
||||
return 0;
|
||||
}
|
||||
@ -2724,9 +2722,9 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
||||
}
|
||||
|
||||
// parse each key:val
|
||||
for(size_t pair_nextpos = restxattrs.find_first_of(','); 0 < restxattrs.length(); restxattrs = (pair_nextpos != string::npos ? restxattrs.substr(pair_nextpos + 1) : string("")), pair_nextpos = restxattrs.find_first_of(',')){
|
||||
string pair = pair_nextpos != string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
|
||||
string key;
|
||||
for(size_t pair_nextpos = restxattrs.find_first_of(','); 0 < restxattrs.length(); restxattrs = (pair_nextpos != std::string::npos ? restxattrs.substr(pair_nextpos + 1) : std::string("")), pair_nextpos = restxattrs.find_first_of(',')){
|
||||
std::string pair = pair_nextpos != std::string::npos ? restxattrs.substr(0, pair_nextpos) : restxattrs;
|
||||
std::string key;
|
||||
PXATTRVAL pval = NULL;
|
||||
if(!parse_xattr_keyval(pair, key, pval)){
|
||||
// something format error, so skip this.
|
||||
@ -2739,7 +2737,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
|
||||
|
||||
static std::string build_xattrs(const xattrs_t& xattrs)
|
||||
{
|
||||
string strxattrs("{");
|
||||
std::string strxattrs("{");
|
||||
|
||||
bool is_set = false;
|
||||
for(xattrs_t::const_iterator iter = xattrs.begin(); iter != xattrs.end(); ++iter){
|
||||
@ -2770,7 +2768,7 @@ static std::string build_xattrs(const xattrs_t& xattrs)
|
||||
|
||||
static int set_xattrs_to_header(headers_t& meta, const char* name, const char* value, size_t size, int flags)
|
||||
{
|
||||
string strxattrs;
|
||||
std::string strxattrs;
|
||||
xattrs_t xattrs;
|
||||
|
||||
headers_t::iterator iter;
|
||||
@ -2796,7 +2794,7 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v
|
||||
|
||||
// add name(do not care overwrite and empty name/value)
|
||||
xattrs_t::iterator xiter;
|
||||
if(xattrs.end() != (xiter = xattrs.find(string(name)))){
|
||||
if(xattrs.end() != (xiter = xattrs.find(std::string(name)))){
|
||||
// found same head. free value.
|
||||
delete xiter->second;
|
||||
}
|
||||
@ -2809,7 +2807,7 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v
|
||||
}else{
|
||||
pval->pvalue = NULL;
|
||||
}
|
||||
xattrs[string(name)] = pval;
|
||||
xattrs[std::string(name)] = pval;
|
||||
|
||||
// build new strxattrs(not encoded) and set it to headers_t
|
||||
meta["x-amz-meta-xattr"] = build_xattrs(xattrs);
|
||||
@ -2840,9 +2838,9 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value,
|
||||
#endif
|
||||
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
headers_t meta;
|
||||
struct stat stbuf;
|
||||
dirtype nDirType = DIRTYPE_UNKNOWN;
|
||||
@ -2906,7 +2904,7 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value,
|
||||
// the file is opened now.
|
||||
|
||||
// get xattr and make new xattr
|
||||
string strxattr;
|
||||
std::string strxattr;
|
||||
if(ent->GetXattr(strxattr)){
|
||||
updatemeta["x-amz-meta-xattr"] = strxattr;
|
||||
}else{
|
||||
@ -2990,13 +2988,13 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t
|
||||
// object does not have xattrs
|
||||
return -ENOATTR;
|
||||
}
|
||||
string strxattrs = hiter->second;
|
||||
std::string strxattrs = hiter->second;
|
||||
|
||||
parse_xattrs(strxattrs, xattrs);
|
||||
|
||||
// search name
|
||||
string strname = name;
|
||||
xattrs_t::iterator xiter = xattrs.find(strname);
|
||||
std::string strname = name;
|
||||
xattrs_t::iterator xiter = xattrs.find(strname);
|
||||
if(xattrs.end() == xiter){
|
||||
// not found name in xattrs
|
||||
free_xattrs(xattrs);
|
||||
@ -3054,7 +3052,7 @@ static int s3fs_listxattr(const char* path, char* list, size_t size)
|
||||
// object does not have xattrs
|
||||
return 0;
|
||||
}
|
||||
string strxattrs = iter->second;
|
||||
std::string strxattrs = iter->second;
|
||||
|
||||
parse_xattrs(strxattrs, xattrs);
|
||||
|
||||
@ -3103,9 +3101,9 @@ static int s3fs_removexattr(const char* path, const char* name)
|
||||
}
|
||||
|
||||
int result;
|
||||
string strpath;
|
||||
string newpath;
|
||||
string nowcache;
|
||||
std::string strpath;
|
||||
std::string newpath;
|
||||
std::string nowcache;
|
||||
headers_t meta;
|
||||
xattrs_t xattrs;
|
||||
struct stat stbuf;
|
||||
@ -3139,13 +3137,13 @@ static int s3fs_removexattr(const char* path, const char* name)
|
||||
// object does not have xattrs
|
||||
return -ENOATTR;
|
||||
}
|
||||
string strxattrs = hiter->second;
|
||||
std::string strxattrs = hiter->second;
|
||||
|
||||
parse_xattrs(strxattrs, xattrs);
|
||||
|
||||
// check name xattrs
|
||||
string strname = name;
|
||||
xattrs_t::iterator xiter = xattrs.find(strname);
|
||||
std::string strname = name;
|
||||
xattrs_t::iterator xiter = xattrs.find(strname);
|
||||
if(xattrs.end() == xiter){
|
||||
free_xattrs(xattrs);
|
||||
return -ENOATTR;
|
||||
@ -3183,7 +3181,7 @@ static int s3fs_removexattr(const char* path, const char* name)
|
||||
if(!xattrs.empty()){
|
||||
updatemeta["x-amz-meta-xattr"] = build_xattrs(xattrs);
|
||||
}else{
|
||||
updatemeta["x-amz-meta-xattr"] = string(""); // This is a special case. If empty, this header will eventually be removed.
|
||||
updatemeta["x-amz-meta-xattr"] = std::string(""); // This is a special case. If empty, this header will eventually be removed.
|
||||
}
|
||||
free_xattrs(xattrs);
|
||||
|
||||
@ -3340,7 +3338,7 @@ static int s3fs_access(const char* path, int mask)
|
||||
//
|
||||
// So this is cheap code but s3fs should get correct region automatically.
|
||||
//
|
||||
static bool check_region_error(const char* pbody, size_t len, string& expectregion)
|
||||
static bool check_region_error(const char* pbody, size_t len, std::string& expectregion)
|
||||
{
|
||||
if(!pbody){
|
||||
return false;
|
||||
@ -3379,7 +3377,7 @@ static int s3fs_check_service()
|
||||
|
||||
// check region error(for putting message or retrying)
|
||||
BodyData* body = s3fscurl.GetBodyData();
|
||||
string expectregion;
|
||||
std::string expectregion;
|
||||
if(check_region_error(body->str(), body->size(), expectregion)){
|
||||
// [NOTE]
|
||||
// If endpoint is not specified(using us-east-1 region) and
|
||||
@ -3472,13 +3470,13 @@ static int s3fs_check_service()
|
||||
//
|
||||
static int parse_passwd_file(bucketkvmap_t& resmap)
|
||||
{
|
||||
string line;
|
||||
std::string line;
|
||||
size_t first_pos;
|
||||
readline_t linelist;
|
||||
readline_t::iterator iter;
|
||||
|
||||
// open passwd file
|
||||
ifstream PF(passwd_file.c_str());
|
||||
std::ifstream PF(passwd_file.c_str());
|
||||
if(!PF.good()){
|
||||
S3FS_PRN_EXIT("could not open passwd file : %s", passwd_file.c_str());
|
||||
return -1;
|
||||
@ -3493,7 +3491,7 @@ static int parse_passwd_file(bucketkvmap_t& resmap)
|
||||
if('#' == line[0]){
|
||||
continue;
|
||||
}
|
||||
if(string::npos != line.find_first_of(" \t")){
|
||||
if(std::string::npos != line.find_first_of(" \t")){
|
||||
S3FS_PRN_EXIT("invalid line in passwd file, found whitespace character.");
|
||||
return -1;
|
||||
}
|
||||
@ -3508,12 +3506,12 @@ static int parse_passwd_file(bucketkvmap_t& resmap)
|
||||
kvmap_t kv;
|
||||
for(iter = linelist.begin(); iter != linelist.end(); ++iter){
|
||||
first_pos = iter->find_first_of("=");
|
||||
if(first_pos == string::npos){
|
||||
if(first_pos == std::string::npos){
|
||||
continue;
|
||||
}
|
||||
// formatted by "key=val"
|
||||
string key = trim(iter->substr(0, first_pos));
|
||||
string val = trim(iter->substr(first_pos + 1, string::npos));
|
||||
std::string key = trim(iter->substr(0, first_pos));
|
||||
std::string val = trim(iter->substr(first_pos + 1, std::string::npos));
|
||||
if(key.empty()){
|
||||
continue;
|
||||
}
|
||||
@ -3524,37 +3522,37 @@ static int parse_passwd_file(bucketkvmap_t& resmap)
|
||||
kv[key] = val;
|
||||
}
|
||||
// set special key name
|
||||
resmap[string(keyval_fields_type)] = kv;
|
||||
resmap[std::string(keyval_fields_type)] = kv;
|
||||
|
||||
// read ':' type
|
||||
for(iter = linelist.begin(); iter != linelist.end(); ++iter){
|
||||
first_pos = iter->find_first_of(":");
|
||||
size_t last_pos = iter->find_last_of(":");
|
||||
if(first_pos == string::npos){
|
||||
if(first_pos == std::string::npos){
|
||||
continue;
|
||||
}
|
||||
string bucketname;
|
||||
string accesskey;
|
||||
string secret;
|
||||
std::string bucketname;
|
||||
std::string accesskey;
|
||||
std::string secret;
|
||||
if(first_pos != last_pos){
|
||||
// formatted by "bucket:accesskey:secretkey"
|
||||
bucketname = trim(iter->substr(0, first_pos));
|
||||
accesskey = trim(iter->substr(first_pos + 1, last_pos - first_pos - 1));
|
||||
secret = trim(iter->substr(last_pos + 1, string::npos));
|
||||
secret = trim(iter->substr(last_pos + 1, std::string::npos));
|
||||
}else{
|
||||
// formatted by "accesskey:secretkey"
|
||||
bucketname = allbucket_fields_type;
|
||||
accesskey = trim(iter->substr(0, first_pos));
|
||||
secret = trim(iter->substr(first_pos + 1, string::npos));
|
||||
secret = trim(iter->substr(first_pos + 1, std::string::npos));
|
||||
}
|
||||
if(resmap.end() != resmap.find(bucketname)){
|
||||
S3FS_PRN_EXIT("there are multiple entries for the same bucket(%s) in the passwd file.", (bucketname.empty() ? "default" : bucketname.c_str()));
|
||||
return -1;
|
||||
}
|
||||
kv.clear();
|
||||
kv[string(aws_accesskeyid)] = accesskey;
|
||||
kv[string(aws_secretkey)] = secret;
|
||||
resmap[bucketname] = kv;
|
||||
kv[std::string(aws_accesskeyid)] = accesskey;
|
||||
kv[std::string(aws_secretkey)] = secret;
|
||||
resmap[bucketname] = kv;
|
||||
}
|
||||
return (resmap.empty() ? 0 : 1);
|
||||
}
|
||||
@ -3566,8 +3564,8 @@ static int parse_passwd_file(bucketkvmap_t& resmap)
|
||||
//
|
||||
static int check_for_aws_format(const kvmap_t& kvmap)
|
||||
{
|
||||
string str1(aws_accesskeyid);
|
||||
string str2(aws_secretkey);
|
||||
std::string str1(aws_accesskeyid);
|
||||
std::string str2(aws_secretkey);
|
||||
|
||||
if(kvmap.empty()){
|
||||
return 0;
|
||||
@ -3643,18 +3641,18 @@ static int check_passwd_file_perms()
|
||||
static int read_aws_credentials_file(const std::string &filename)
|
||||
{
|
||||
// open passwd file
|
||||
ifstream PF(filename.c_str());
|
||||
std::ifstream PF(filename.c_str());
|
||||
if(!PF.good()){
|
||||
return -1;
|
||||
}
|
||||
|
||||
string profile;
|
||||
string accesskey;
|
||||
string secret;
|
||||
string session_token;
|
||||
std::string profile;
|
||||
std::string accesskey;
|
||||
std::string secret;
|
||||
std::string session_token;
|
||||
|
||||
// read each line
|
||||
string line;
|
||||
std::string line;
|
||||
while(getline(PF, line)){
|
||||
line = trim(line);
|
||||
if(line.empty()){
|
||||
@ -3675,11 +3673,11 @@ static int read_aws_credentials_file(const std::string &filename)
|
||||
}
|
||||
|
||||
size_t pos = line.find_first_of('=');
|
||||
if(pos == string::npos){
|
||||
if(pos == std::string::npos){
|
||||
continue;
|
||||
}
|
||||
string key = trim(line.substr(0, pos));
|
||||
string value = trim(line.substr(pos + 1, string::npos));
|
||||
std::string key = trim(line.substr(0, pos));
|
||||
std::string value = trim(line.substr(pos + 1, std::string::npos));
|
||||
if(key == "aws_access_key_id"){
|
||||
accesskey = value;
|
||||
}else if(key == "aws_secret_access_key"){
|
||||
@ -3763,7 +3761,7 @@ static int read_passwd_file()
|
||||
}
|
||||
}
|
||||
|
||||
string bucket_key = allbucket_fields_type;
|
||||
std::string bucket_key = allbucket_fields_type;
|
||||
if(!bucket.empty() && bucketmap.end() != bucketmap.find(bucket)){
|
||||
bucket_key = bucket;
|
||||
}
|
||||
@ -3822,7 +3820,7 @@ static int get_access_keys()
|
||||
|
||||
// 2 - was specified on the command line
|
||||
if(!passwd_file.empty()){
|
||||
ifstream PF(passwd_file.c_str());
|
||||
std::ifstream PF(passwd_file.c_str());
|
||||
if(PF.good()){
|
||||
PF.close();
|
||||
return read_passwd_file();
|
||||
@ -3869,7 +3867,7 @@ static int get_access_keys()
|
||||
if(AWS_CREDENTIAL_FILE != NULL){
|
||||
passwd_file.assign(AWS_CREDENTIAL_FILE);
|
||||
if(!passwd_file.empty()){
|
||||
ifstream PF(passwd_file.c_str());
|
||||
std::ifstream PF(passwd_file.c_str());
|
||||
if(PF.good()){
|
||||
PF.close();
|
||||
return read_passwd_file();
|
||||
@ -3895,7 +3893,7 @@ static int get_access_keys()
|
||||
if(HOME != NULL){
|
||||
passwd_file.assign(HOME);
|
||||
passwd_file.append("/.passwd-s3fs");
|
||||
ifstream PF(passwd_file.c_str());
|
||||
std::ifstream PF(passwd_file.c_str());
|
||||
if(PF.good()){
|
||||
PF.close();
|
||||
if(EXIT_SUCCESS != read_passwd_file()){
|
||||
@ -3912,7 +3910,7 @@ static int get_access_keys()
|
||||
|
||||
// 5 - from the system default location
|
||||
passwd_file.assign("/etc/passwd-s3fs");
|
||||
ifstream PF(passwd_file.c_str());
|
||||
std::ifstream PF(passwd_file.c_str());
|
||||
if(PF.good()){
|
||||
PF.close();
|
||||
return read_passwd_file();
|
||||
@ -4290,7 +4288,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
if(0 == STR2NCMP(arg, "ibm_iam_endpoint=")){
|
||||
std::string endpoint_url;
|
||||
std::string iam_endpoint = strchr(arg, '=') + sizeof(char);
|
||||
// Check url for http / https protocol string
|
||||
// Check url for http / https protocol std::string
|
||||
if((iam_endpoint.compare(0, 8, "https://") != 0) && (iam_endpoint.compare(0, 7, "http://") != 0)) {
|
||||
S3FS_PRN_EXIT("option ibm_iam_endpoint has invalid format, missing http / https protocol");
|
||||
return -1;
|
||||
@ -4443,7 +4441,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
return 0;
|
||||
}
|
||||
if(0 == STR2NCMP(arg, "ahbe_conf=")){
|
||||
string ahbe_conf = strchr(arg, '=') + sizeof(char);
|
||||
std::string ahbe_conf = strchr(arg, '=') + sizeof(char);
|
||||
if(!AdditionalHeader::get()->Load(ahbe_conf.c_str())){
|
||||
S3FS_PRN_EXIT("failed to load ahbe_conf file(%s).", ahbe_conf.c_str());
|
||||
return -1;
|
||||
@ -4490,7 +4488,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
if(0 == STR2NCMP(arg, "url=")){
|
||||
s3host = strchr(arg, '=') + sizeof(char);
|
||||
// strip the trailing '/', if any, off the end of the host
|
||||
// string
|
||||
// std::string
|
||||
size_t found, length;
|
||||
found = s3host.find_last_of('/');
|
||||
length = s3host.length();
|
||||
@ -4499,7 +4497,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
found = s3host.find_last_of('/');
|
||||
length = s3host.length();
|
||||
}
|
||||
// Check url for http / https protocol string
|
||||
// Check url for http / https protocol std::string
|
||||
if((s3host.compare(0, 8, "https://") != 0) && (s3host.compare(0, 7, "http://") != 0)) {
|
||||
S3FS_PRN_EXIT("option url has invalid format, missing http / https protocol");
|
||||
return -1;
|
||||
@ -4694,7 +4692,7 @@ int main(int argc, char* argv[])
|
||||
// get program name - emulate basename
|
||||
program_name.assign(argv[0]);
|
||||
size_t found = program_name.find_last_of('/');
|
||||
if(found != string::npos){
|
||||
if(found != std::string::npos){
|
||||
program_name.replace(0, found+1, "");
|
||||
}
|
||||
|
||||
@ -4835,14 +4833,14 @@ int main(int argc, char* argv[])
|
||||
|
||||
// check bucket name for illegal characters
|
||||
found = bucket.find_first_of("/:\\;!@#$%^&*?|+=");
|
||||
if(found != string::npos){
|
||||
if(found != std::string::npos){
|
||||
S3FS_PRN_EXIT("BUCKET %s -- bucket name contains an illegal character.", bucket.c_str());
|
||||
S3fsCurl::DestroyS3fsCurl();
|
||||
s3fs_destroy_global_ssl();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(!pathrequeststyle && STR2NCMP(s3host.c_str(), "https://") == 0 && bucket.find_first_of('.') != string::npos) {
|
||||
if(!pathrequeststyle && STR2NCMP(s3host.c_str(), "https://") == 0 && bucket.find_first_of('.') != std::string::npos) {
|
||||
S3FS_PRN_EXIT("BUCKET %s -- cannot mount bucket with . while using HTTPS without use_path_request_style", bucket.c_str());
|
||||
S3fsCurl::DestroyS3fsCurl();
|
||||
s3fs_destroy_global_ssl();
|
||||
@ -4938,9 +4936,9 @@ int main(int argc, char* argv[])
|
||||
/*
|
||||
if(1 == S3fsCurl::GetSslVerifyHostname()){
|
||||
found = bucket.find_first_of(".");
|
||||
if(found != string::npos){
|
||||
if(found != std::string::npos){
|
||||
found = s3host.find("https:");
|
||||
if(found != string::npos){
|
||||
if(found != std::string::npos){
|
||||
S3FS_PRN_EXIT("Using https and a bucket name with periods is unsupported.");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include "s3fs_help.h"
|
||||
#include "s3fs_auth.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Contents
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -37,8 +37,6 @@
|
||||
#include "s3fs_util.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Global variables
|
||||
//-------------------------------------------------------------------
|
||||
@ -50,9 +48,9 @@ static size_t max_group_name_length;
|
||||
//-------------------------------------------------------------------
|
||||
// Utilities
|
||||
//-------------------------------------------------------------------
|
||||
string get_realpath(const char *path)
|
||||
std::string get_realpath(const char *path)
|
||||
{
|
||||
string realpath = mount_prefix;
|
||||
std::string realpath = mount_prefix;
|
||||
realpath += path;
|
||||
|
||||
return realpath;
|
||||
@ -91,7 +89,7 @@ void init_sysconf_vars()
|
||||
// Utility for UID/GID
|
||||
//-------------------------------------------------------------------
|
||||
// get user name from uid
|
||||
string get_username(uid_t uid)
|
||||
std::string get_username(uid_t uid)
|
||||
{
|
||||
size_t maxlen = max_password_size;
|
||||
int result;
|
||||
@ -111,15 +109,15 @@ string get_username(uid_t uid)
|
||||
if(0 != result){
|
||||
S3FS_PRN_ERR("could not get pw information(%d).", result);
|
||||
delete[] pbuf;
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
// check pw
|
||||
if(NULL == ppwinfo){
|
||||
delete[] pbuf;
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
string name = SAFESTRPTR(ppwinfo->pw_name);
|
||||
std::string name = SAFESTRPTR(ppwinfo->pw_name);
|
||||
delete[] pbuf;
|
||||
return name;
|
||||
}
|
||||
@ -154,7 +152,7 @@ int is_uid_include_group(uid_t uid, gid_t gid)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
string username = get_username(uid);
|
||||
std::string username = get_username(uid);
|
||||
|
||||
char** ppgr_mem;
|
||||
for(ppgr_mem = pginfo->gr_mem; ppgr_mem && *ppgr_mem; ppgr_mem++){
|
||||
@ -171,42 +169,42 @@ int is_uid_include_group(uid_t uid, gid_t gid)
|
||||
//-------------------------------------------------------------------
|
||||
// Utility for file and directory
|
||||
//-------------------------------------------------------------------
|
||||
string mydirname(const string& path)
|
||||
std::string mydirname(const std::string& path)
|
||||
{
|
||||
return string(dirname((char*)path.c_str()));
|
||||
return std::string(dirname((char*)path.c_str()));
|
||||
}
|
||||
|
||||
// safe variant of dirname
|
||||
// dirname clobbers path so let it operate on a tmp copy
|
||||
string mydirname(const char* path)
|
||||
std::string mydirname(const char* path)
|
||||
{
|
||||
if(!path || '\0' == path[0]){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
return mydirname(string(path));
|
||||
return mydirname(std::string(path));
|
||||
}
|
||||
|
||||
string mybasename(const string& path)
|
||||
std::string mybasename(const std::string& path)
|
||||
{
|
||||
return string(basename((char*)path.c_str()));
|
||||
return std::string(basename((char*)path.c_str()));
|
||||
}
|
||||
|
||||
// safe variant of basename
|
||||
// basename clobbers path so let it operate on a tmp copy
|
||||
string mybasename(const char* path)
|
||||
std::string mybasename(const char* path)
|
||||
{
|
||||
if(!path || '\0' == path[0]){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
return mybasename(string(path));
|
||||
return mybasename(std::string(path));
|
||||
}
|
||||
|
||||
// mkdir --parents
|
||||
int mkdirp(const string& path, mode_t mode)
|
||||
int mkdirp(const std::string& path, mode_t mode)
|
||||
{
|
||||
string base;
|
||||
string component;
|
||||
istringstream ss(path);
|
||||
std::string base;
|
||||
std::string component;
|
||||
std::istringstream ss(path);
|
||||
while (getline(ss, component, '/')) {
|
||||
base += "/" + component;
|
||||
|
||||
@ -225,12 +223,12 @@ int mkdirp(const string& path, mode_t mode)
|
||||
}
|
||||
|
||||
// get existed directory path
|
||||
string get_exist_directory_path(const string& path)
|
||||
std::string get_exist_directory_path(const std::string& path)
|
||||
{
|
||||
string existed("/"); // "/" is existed.
|
||||
string base;
|
||||
string component;
|
||||
istringstream ss(path);
|
||||
std::string existed("/"); // "/" is existed.
|
||||
std::string base;
|
||||
std::string component;
|
||||
std::istringstream ss(path);
|
||||
while (getline(ss, component, '/')) {
|
||||
if(base != "/"){
|
||||
base += "/";
|
||||
@ -307,9 +305,9 @@ bool delete_files_in_dir(const char* dir, bool is_remove_own)
|
||||
if(0 == strcmp(dent->d_name, "..") || 0 == strcmp(dent->d_name, ".")){
|
||||
continue;
|
||||
}
|
||||
string fullpath = dir;
|
||||
fullpath += "/";
|
||||
fullpath += dent->d_name;
|
||||
std::string fullpath = dir;
|
||||
fullpath += "/";
|
||||
fullpath += dent->d_name;
|
||||
struct stat st;
|
||||
if(0 != lstat(fullpath.c_str(), &st)){
|
||||
S3FS_PRN_ERR("could not get stats of file(%s) - errno(%d)", fullpath.c_str(), errno);
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include "s3fs_xml.h"
|
||||
#include "s3fs_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Variables
|
||||
//-------------------------------------------------------------------
|
||||
@ -36,10 +34,10 @@ static const char* c_strErrorObjectName = "FILE or SUBDIR in DIR";
|
||||
//-------------------------------------------------------------------
|
||||
// Functions
|
||||
//-------------------------------------------------------------------
|
||||
static bool GetXmlNsUrl(xmlDocPtr doc, string& nsurl)
|
||||
static bool GetXmlNsUrl(xmlDocPtr doc, std::string& nsurl)
|
||||
{
|
||||
static time_t tmLast = 0; // cache for 60 sec.
|
||||
static string strNs;
|
||||
static std::string strNs;
|
||||
bool result = false;
|
||||
|
||||
if(!doc){
|
||||
@ -70,8 +68,8 @@ static bool GetXmlNsUrl(xmlDocPtr doc, string& nsurl)
|
||||
static xmlChar* get_base_exp(xmlDocPtr doc, const char* exp)
|
||||
{
|
||||
xmlXPathObjectPtr marker_xp;
|
||||
string xmlnsurl;
|
||||
string exp_string;
|
||||
std::string xmlnsurl;
|
||||
std::string exp_string;
|
||||
|
||||
if(!doc){
|
||||
return NULL;
|
||||
@ -134,8 +132,8 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
||||
}
|
||||
|
||||
// Make dir path and filename
|
||||
string strdirpath = mydirname(string((char*)fullpath));
|
||||
string strmybpath = mybasename(string((char*)fullpath));
|
||||
std::string strdirpath = mydirname(std::string((char*)fullpath));
|
||||
std::string strmybpath = mybasename(std::string((char*)fullpath));
|
||||
const char* dirpath = strdirpath.c_str();
|
||||
const char* mybname = strmybpath.c_str();
|
||||
const char* basepath= (path && '/' == path[0]) ? &path[1] : path;
|
||||
@ -168,7 +166,7 @@ static char* get_object_name(xmlDocPtr doc, xmlNodePtr node, const char* path)
|
||||
// OK
|
||||
return strdup(mybname);
|
||||
}else if(basepath && 0 < strlen(basepath) && '/' == basepath[strlen(basepath) - 1] && 0 == strncmp(dirpath, basepath, strlen(basepath) - 1)){
|
||||
string withdirname;
|
||||
std::string withdirname;
|
||||
if(strlen(dirpath) > strlen(basepath)){
|
||||
withdirname = &dirpath[strlen(basepath)];
|
||||
}
|
||||
@ -224,11 +222,11 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list)
|
||||
|
||||
xmlXPathContextPtr ctx = xmlXPathNewContext(doc);;
|
||||
|
||||
string xmlnsurl;
|
||||
string ex_upload = "//";
|
||||
string ex_key;
|
||||
string ex_id;
|
||||
string ex_date;
|
||||
std::string xmlnsurl;
|
||||
std::string ex_upload = "//";
|
||||
std::string ex_key;
|
||||
std::string ex_id;
|
||||
std::string ex_date;
|
||||
|
||||
if(!noxmlns && GetXmlNsUrl(doc, xmlnsurl)){
|
||||
xmlXPathRegisterNs(ctx, (xmlChar*)"s3", (xmlChar*)xmlnsurl.c_str());
|
||||
@ -331,9 +329,9 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
|
||||
}
|
||||
content_nodes = contents_xp->nodesetval;
|
||||
|
||||
bool is_dir;
|
||||
string stretag;
|
||||
int i;
|
||||
bool is_dir;
|
||||
std::string stretag;
|
||||
int i;
|
||||
for(i = 0; i < content_nodes->nodeNr; i++){
|
||||
ctx->node = content_nodes->nodeTab[i];
|
||||
|
||||
@ -396,12 +394,12 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
|
||||
|
||||
int append_objects_from_xml(const char* path, xmlDocPtr doc, S3ObjList& head)
|
||||
{
|
||||
string xmlnsurl;
|
||||
string ex_contents = "//";
|
||||
string ex_key;
|
||||
string ex_cprefix = "//";
|
||||
string ex_prefix;
|
||||
string ex_etag;
|
||||
std::string xmlnsurl;
|
||||
std::string ex_contents = "//";
|
||||
std::string ex_key;
|
||||
std::string ex_cprefix = "//";
|
||||
std::string ex_prefix;
|
||||
std::string ex_etag;
|
||||
|
||||
if(!doc){
|
||||
return -1;
|
||||
@ -409,7 +407,7 @@ int append_objects_from_xml(const char* path, xmlDocPtr doc, S3ObjList& head)
|
||||
|
||||
// If there is not <Prefix>, use path instead of it.
|
||||
xmlChar* pprefix = get_prefix(doc);
|
||||
string prefix = (pprefix ? (char*)pprefix : path ? path : "");
|
||||
std::string prefix = (pprefix ? (char*)pprefix : path ? path : "");
|
||||
if(pprefix){
|
||||
xmlFree(pprefix);
|
||||
}
|
||||
@ -465,11 +463,11 @@ bool simple_parse_xml(const char* data, size_t len, const char* key, std::string
|
||||
}
|
||||
for(xmlNodePtr cur_node = doc->children->children; NULL != cur_node; cur_node = cur_node->next){
|
||||
// For DEBUG
|
||||
// string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
||||
// std::string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
||||
// printf("cur_node_name: %s\n", cur_node_name.c_str());
|
||||
|
||||
if(XML_ELEMENT_NODE == cur_node->type){
|
||||
string elementName = reinterpret_cast<const char*>(cur_node->name);
|
||||
std::string elementName = reinterpret_cast<const char*>(cur_node->name);
|
||||
// For DEBUG
|
||||
// printf("elementName: %s\n", elementName.c_str());
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "s3objlist.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Class S3ObjList
|
||||
//-------------------------------------------------------------------
|
||||
@ -44,12 +42,12 @@ bool S3ObjList::insert(const char* name, const char* etag, bool is_dir)
|
||||
}
|
||||
|
||||
s3obj_t::iterator iter;
|
||||
string newname;
|
||||
string orgname = name;
|
||||
std::string newname;
|
||||
std::string orgname = name;
|
||||
|
||||
// Normalization
|
||||
string::size_type pos = orgname.find("_$folder$");
|
||||
if(string::npos != pos){
|
||||
std::string::size_type pos = orgname.find("_$folder$");
|
||||
if(std::string::npos != pos){
|
||||
newname = orgname.substr(0, pos);
|
||||
is_dir = true;
|
||||
}else{
|
||||
@ -67,13 +65,13 @@ bool S3ObjList::insert(const char* name, const char* etag, bool is_dir)
|
||||
|
||||
// Check derived name object.
|
||||
if(is_dir){
|
||||
string chkname = newname.substr(0, newname.length() - 1);
|
||||
std::string chkname = newname.substr(0, newname.length() - 1);
|
||||
if(objects.end() != (iter = objects.find(chkname))){
|
||||
// found "dir" object --> remove it.
|
||||
objects.erase(iter);
|
||||
}
|
||||
}else{
|
||||
string chkname = newname + "/";
|
||||
std::string chkname = newname + "/";
|
||||
if(objects.end() != (iter = objects.find(chkname))){
|
||||
// found "dir/" object --> not add new object.
|
||||
// and add normalization
|
||||
@ -88,7 +86,7 @@ bool S3ObjList::insert(const char* name, const char* etag, bool is_dir)
|
||||
(*iter).second.orgname = orgname;
|
||||
(*iter).second.is_dir = is_dir;
|
||||
if(etag){
|
||||
(*iter).second.etag = string(etag); // over write
|
||||
(*iter).second.etag = std::string(etag); // over write
|
||||
}
|
||||
}else{
|
||||
// add new object
|
||||
@ -144,44 +142,44 @@ const s3obj_entry* S3ObjList::GetS3Obj(const char* name) const
|
||||
return &((*iter).second);
|
||||
}
|
||||
|
||||
string S3ObjList::GetOrgName(const char* name) const
|
||||
std::string S3ObjList::GetOrgName(const char* name) const
|
||||
{
|
||||
const s3obj_entry* ps3obj;
|
||||
|
||||
if(!name || '\0' == name[0]){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
return ps3obj->orgname;
|
||||
}
|
||||
|
||||
string S3ObjList::GetNormalizedName(const char* name) const
|
||||
std::string S3ObjList::GetNormalizedName(const char* name) const
|
||||
{
|
||||
const s3obj_entry* ps3obj;
|
||||
|
||||
if(!name || '\0' == name[0]){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
if(0 == (ps3obj->normalname).length()){
|
||||
return string(name);
|
||||
return std::string(name);
|
||||
}
|
||||
return ps3obj->normalname;
|
||||
}
|
||||
|
||||
string S3ObjList::GetETag(const char* name) const
|
||||
std::string S3ObjList::GetETag(const char* name) const
|
||||
{
|
||||
const s3obj_entry* ps3obj;
|
||||
|
||||
if(!name || '\0' == name[0]){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
if(NULL == (ps3obj = GetS3Obj(name))){
|
||||
return string("");
|
||||
return std::string("");
|
||||
}
|
||||
return ps3obj->etag;
|
||||
}
|
||||
@ -224,9 +222,9 @@ bool S3ObjList::GetNameList(s3obj_list_t& list, bool OnlyNormalized, bool CutSla
|
||||
if(OnlyNormalized && 0 != (*iter).second.normalname.length()){
|
||||
continue;
|
||||
}
|
||||
string name = (*iter).first;
|
||||
std::string name = (*iter).first;
|
||||
if(CutSlash && 1 < name.length() && '/' == name[name.length() - 1]){
|
||||
// only "/" string is skipped this.
|
||||
// only "/" std::string is skipped this.
|
||||
name = name.substr(0, name.length() - 1);
|
||||
}
|
||||
list.push_back(name);
|
||||
@ -243,14 +241,14 @@ bool S3ObjList::MakeHierarchizedList(s3obj_list_t& list, bool haveSlash)
|
||||
s3obj_list_t::const_iterator liter;
|
||||
|
||||
for(liter = list.begin(); list.end() != liter; ++liter){
|
||||
string strtmp = (*liter);
|
||||
std::string strtmp = (*liter);
|
||||
if(1 < strtmp.length() && '/' == strtmp[strtmp.length() - 1]){
|
||||
strtmp = strtmp.substr(0, strtmp.length() - 1);
|
||||
}
|
||||
h_map[strtmp] = true;
|
||||
|
||||
// check hierarchized directory
|
||||
for(string::size_type pos = strtmp.find_last_of('/'); string::npos != pos; pos = strtmp.find_last_of('/')){
|
||||
for(std::string::size_type pos = strtmp.find_last_of('/'); std::string::npos != pos; pos = strtmp.find_last_of('/')){
|
||||
strtmp = strtmp.substr(0, pos);
|
||||
if(0 == strtmp.length() || "/" == strtmp){
|
||||
break;
|
||||
@ -266,7 +264,7 @@ bool S3ObjList::MakeHierarchizedList(s3obj_list_t& list, bool haveSlash)
|
||||
for(hiter = h_map.begin(); hiter != h_map.end(); ++hiter){
|
||||
if(false == (*hiter).second){
|
||||
// add hierarchized directory.
|
||||
string strtmp = (*hiter).first;
|
||||
std::string strtmp = (*hiter).first;
|
||||
if(haveSlash){
|
||||
strtmp += "/";
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include "sighandlers.h"
|
||||
#include "fdcache.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Class S3fsSignals
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "string_util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Gloval variables
|
||||
//-------------------------------------------------------------------
|
||||
@ -88,11 +86,11 @@ bool try_strtoofft(const char* str, off_t& value, int base)
|
||||
try{
|
||||
value = s3fs_strtoofft(str, base);
|
||||
}catch(std::exception &e){
|
||||
S3FS_PRN_WARN("something error is occurred in convert string(%s) to off_t.", str);
|
||||
S3FS_PRN_WARN("something error is occurred in convert std::string(%s) to off_t.", str);
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
S3FS_PRN_WARN("parameter string is null.");
|
||||
S3FS_PRN_WARN("parameter std::string is null.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -107,39 +105,39 @@ off_t cvt_strtoofft(const char* str, int base)
|
||||
{
|
||||
off_t result = 0;
|
||||
if(!try_strtoofft(str, result, base)){
|
||||
S3FS_PRN_WARN("something error is occurred in convert string(%s) to off_t, thus return 0 as default.", (str ? str : "null"));
|
||||
S3FS_PRN_WARN("something error is occurred in convert std::string(%s) to off_t, thus return 0 as default.", (str ? str : "null"));
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string lower(string s)
|
||||
std::string lower(std::string s)
|
||||
{
|
||||
// change each character of the string to lower case
|
||||
// change each character of the std::string to lower case
|
||||
for(size_t i = 0; i < s.length(); i++){
|
||||
s[i] = tolower(s[i]);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
string trim_left(const string &s, const string &t /* = SPACES */)
|
||||
std::string trim_left(const std::string &s, const std::string &t /* = SPACES */)
|
||||
{
|
||||
string d(s);
|
||||
std::string d(s);
|
||||
return d.erase(0, s.find_first_not_of(t));
|
||||
}
|
||||
|
||||
string trim_right(const string &s, const string &t /* = SPACES */)
|
||||
std::string trim_right(const std::string &s, const std::string &t /* = SPACES */)
|
||||
{
|
||||
string d(s);
|
||||
string::size_type i(d.find_last_not_of(t));
|
||||
if(i == string::npos){
|
||||
std::string d(s);
|
||||
std::string::size_type i(d.find_last_not_of(t));
|
||||
if(i == std::string::npos){
|
||||
return "";
|
||||
}else{
|
||||
return d.erase(d.find_last_not_of(t) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
string trim(const string &s, const string &t /* = SPACES */)
|
||||
std::string trim(const std::string &s, const std::string &t /* = SPACES */)
|
||||
{
|
||||
return trim_left(trim_right(s, t), t);
|
||||
}
|
||||
@ -149,9 +147,9 @@ string trim(const string &s, const string &t /* = SPACES */)
|
||||
// taking into special consideration "/",
|
||||
// otherwise regular urlEncode.
|
||||
//
|
||||
string urlEncode(const string &s)
|
||||
std::string urlEncode(const std::string &s)
|
||||
{
|
||||
string result;
|
||||
std::string result;
|
||||
for (size_t i = 0; i < s.length(); ++i) {
|
||||
char c = s[i];
|
||||
if (c == '/' // Note- special case for fuse paths...
|
||||
@ -178,9 +176,9 @@ string urlEncode(const string &s)
|
||||
// taking into special consideration "/",
|
||||
// otherwise regular urlEncode.
|
||||
//
|
||||
string urlEncode2(const string &s)
|
||||
std::string urlEncode2(const std::string &s)
|
||||
{
|
||||
string result;
|
||||
std::string result;
|
||||
for (size_t i = 0; i < s.length(); ++i) {
|
||||
char c = s[i];
|
||||
if (c == '=' // Note- special case for fuse paths...
|
||||
@ -204,9 +202,9 @@ string urlEncode2(const string &s)
|
||||
return result;
|
||||
}
|
||||
|
||||
string urlDecode(const string& s)
|
||||
std::string urlDecode(const std::string& s)
|
||||
{
|
||||
string result;
|
||||
std::string result;
|
||||
for(size_t i = 0; i < s.length(); ++i){
|
||||
if(s[i] != '%'){
|
||||
result += s[i];
|
||||
@ -227,20 +225,20 @@ string urlDecode(const string& s)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool takeout_str_dquart(string& str)
|
||||
bool takeout_str_dquart(std::string& str)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
// '"' for start
|
||||
if(string::npos != (pos = str.find_first_of('\"'))){
|
||||
if(std::string::npos != (pos = str.find_first_of('\"'))){
|
||||
str = str.substr(pos + 1);
|
||||
|
||||
// '"' for end
|
||||
if(string::npos == (pos = str.find_last_of('\"'))){
|
||||
if(std::string::npos == (pos = str.find_last_of('\"'))){
|
||||
return false;
|
||||
}
|
||||
str = str.substr(0, pos);
|
||||
if(string::npos != str.find_first_of('\"')){
|
||||
if(std::string::npos != str.find_first_of('\"')){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -250,14 +248,14 @@ bool takeout_str_dquart(string& str)
|
||||
//
|
||||
// ex. target="http://......?keyword=value&..."
|
||||
//
|
||||
bool get_keyword_value(string& target, const char* keyword, string& value)
|
||||
bool get_keyword_value(std::string& target, const char* keyword, std::string& value)
|
||||
{
|
||||
if(!keyword){
|
||||
return false;
|
||||
}
|
||||
size_t spos;
|
||||
size_t epos;
|
||||
if(string::npos == (spos = target.find(keyword))){
|
||||
if(std::string::npos == (spos = target.find(keyword))){
|
||||
return false;
|
||||
}
|
||||
spos += strlen(keyword);
|
||||
@ -265,7 +263,7 @@ bool get_keyword_value(string& target, const char* keyword, string& value)
|
||||
return false;
|
||||
}
|
||||
spos++;
|
||||
if(string::npos == (epos = target.find('&', spos))){
|
||||
if(std::string::npos == (epos = target.find('&', spos))){
|
||||
value = target.substr(spos);
|
||||
}else{
|
||||
value = target.substr(spos, (epos - spos));
|
||||
@ -277,7 +275,7 @@ bool get_keyword_value(string& target, const char* keyword, string& value)
|
||||
// Returns the current date
|
||||
// in a format suitable for a HTTP request header.
|
||||
//
|
||||
string get_date_rfc850()
|
||||
std::string get_date_rfc850()
|
||||
{
|
||||
char buf[100];
|
||||
time_t t = time(NULL);
|
||||
@ -286,14 +284,14 @@ string get_date_rfc850()
|
||||
return buf;
|
||||
}
|
||||
|
||||
void get_date_sigv3(string& date, string& date8601)
|
||||
void get_date_sigv3(std::string& date, std::string& date8601)
|
||||
{
|
||||
time_t tm = time(NULL);
|
||||
date = get_date_string(tm);
|
||||
date8601 = get_date_iso8601(tm);
|
||||
}
|
||||
|
||||
string get_date_string(time_t tm)
|
||||
std::string get_date_string(time_t tm)
|
||||
{
|
||||
char buf[100];
|
||||
struct tm res;
|
||||
@ -301,7 +299,7 @@ string get_date_string(time_t tm)
|
||||
return buf;
|
||||
}
|
||||
|
||||
string get_date_iso8601(time_t tm)
|
||||
std::string get_date_iso8601(time_t tm)
|
||||
{
|
||||
char buf[100];
|
||||
struct tm res;
|
||||
@ -326,7 +324,7 @@ bool get_unixtime_from_iso8601(const char* pdate, time_t& unixtime)
|
||||
}
|
||||
|
||||
//
|
||||
// Convert to unixtime from string which formatted by following:
|
||||
// Convert to unixtime from std::string which formatted by following:
|
||||
// "12Y12M12D12h12m12s", "86400s", "9h30m", etc
|
||||
//
|
||||
bool convert_unixtime_from_option_arg(const char* argv, time_t& unixtime)
|
||||
@ -487,7 +485,7 @@ static unsigned int escape_base = 0xe000;
|
||||
|
||||
// encode bytes into wobbly utf8.
|
||||
// 'result' can be null. returns true if transform was needed.
|
||||
bool s3fs_wtf8_encode(const char *s, string *result)
|
||||
bool s3fs_wtf8_encode(const char *s, std::string *result)
|
||||
{
|
||||
bool invalid = false;
|
||||
|
||||
@ -506,7 +504,7 @@ bool s3fs_wtf8_encode(const char *s, string *result)
|
||||
// otherwise, it must be one of the valid start bytes
|
||||
if ( c >= 0xc2 && c <= 0xf5 ) {
|
||||
// two byte encoding
|
||||
// don't need bounds check, string is zero terminated
|
||||
// don't need bounds check, std::string is zero terminated
|
||||
if ((c & 0xe0) == 0xc0 && (s[1] & 0xc0) == 0x80) {
|
||||
// all two byte encodings starting higher than c1 are valid
|
||||
if (result) {
|
||||
@ -557,16 +555,16 @@ bool s3fs_wtf8_encode(const char *s, string *result)
|
||||
return invalid;
|
||||
}
|
||||
|
||||
string s3fs_wtf8_encode(const string &s)
|
||||
std::string s3fs_wtf8_encode(const std::string &s)
|
||||
{
|
||||
string result;
|
||||
std::string result;
|
||||
s3fs_wtf8_encode(s.c_str(), &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// The reverse operation, turn encoded bytes back into their original values
|
||||
// The code assumes that we map to a three-byte code point.
|
||||
bool s3fs_wtf8_decode(const char *s, string *result)
|
||||
bool s3fs_wtf8_decode(const char *s, std::string *result)
|
||||
{
|
||||
bool encoded = false;
|
||||
for (; *s; s++) {
|
||||
@ -593,9 +591,9 @@ bool s3fs_wtf8_decode(const char *s, string *result)
|
||||
return encoded;
|
||||
}
|
||||
|
||||
string s3fs_wtf8_decode(const string &s)
|
||||
std::string s3fs_wtf8_decode(const std::string &s)
|
||||
{
|
||||
string result;
|
||||
std::string result;
|
||||
s3fs_wtf8_decode(s.c_str(), &result);
|
||||
return result;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ void test_strtoofft()
|
||||
|
||||
void test_wtf8_encoding()
|
||||
{
|
||||
std::string ascii("normal string");
|
||||
std::string ascii("normal std::string");
|
||||
std::string utf8("Hyld\xc3\xbdpi \xc3\xbej\xc3\xb3\xc3\xb0""f\xc3\xa9lagsins vex \xc3\xbar k\xc3\xa6rkomnu b\xc3\xb6li \xc3\xad \xc3\xa1st");
|
||||
std::string cp1252("Hyld\xfdpi \xfej\xf3\xf0""f\xe9lagsins vex \xfar k\xe6rkomnu b\xf6li \xed \xe1st");
|
||||
std::string broken = utf8;
|
||||
|
Loading…
x
Reference in New Issue
Block a user