diff --git a/src/addhead.cpp b/src/addhead.cpp index 0712f07..a113923 100644 --- a/src/addhead.cpp +++ b/src/addhead.cpp @@ -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()); diff --git a/src/autolock.cpp b/src/autolock.cpp index 4152845..bb8b322 100644 --- a/src/autolock.cpp +++ b/src/autolock.cpp @@ -26,8 +26,6 @@ #include "s3fs.h" #include "autolock.h" -using namespace std; - //------------------------------------------------------------------- // Class AutoLock //------------------------------------------------------------------- diff --git a/src/bodydata.cpp b/src/bodydata.cpp index 3fb4faf..3e94669 100644 --- a/src/bodydata.cpp +++ b/src/bodydata.cpp @@ -25,8 +25,6 @@ #include "s3fs.h" #include "bodydata.h" -using namespace std; - //------------------------------------------------------------------- // Variables //------------------------------------------------------------------- diff --git a/src/cache.cpp b/src/cache.cpp index 8933567..43f18e1 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -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); } diff --git a/src/common_auth.cpp b/src/common_auth.cpp index 94bc0f0..2c81fbe 100644 --- a/src/common_auth.cpp +++ b/src/common_auth.cpp @@ -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); } /* diff --git a/src/curl.cpp b/src/curl.cpp index fcca70e..11503e0 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -37,8 +37,6 @@ #include "string_util.h" #include "addhead.h" -using namespace std; - //------------------------------------------------------------------- // Symbols //------------------------------------------------------------------- @@ -106,26 +104,26 @@ sse_type_t S3fsCurl::ssetype = sse_type_t::SSE_DISABLE; bool S3fsCurl::is_content_md5 = false; bool S3fsCurl::is_verbose = false; bool S3fsCurl::is_dump_body = false; -string S3fsCurl::AWSAccessKeyId; -string S3fsCurl::AWSSecretAccessKey; -string S3fsCurl::AWSAccessToken; +std::string S3fsCurl::AWSAccessKeyId; +std::string S3fsCurl::AWSSecretAccessKey; +std::string S3fsCurl::AWSAccessToken; time_t S3fsCurl::AWSAccessTokenExpire= 0; bool S3fsCurl::is_ecs = false; bool S3fsCurl::is_ibm_iam_auth = false; -string S3fsCurl::IAM_cred_url = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"; +std::string S3fsCurl::IAM_cred_url = "http://169.254.169.254/latest/meta-data/iam/security-credentials/"; size_t S3fsCurl::IAM_field_count = 4; -string S3fsCurl::IAM_token_field = "Token"; -string S3fsCurl::IAM_expiry_field = "Expiration"; -string S3fsCurl::IAM_role; +std::string S3fsCurl::IAM_token_field = "Token"; +std::string S3fsCurl::IAM_expiry_field = "Expiration"; +std::string S3fsCurl::IAM_role; long S3fsCurl::ssl_verify_hostname = 1; // default(original code...) // protected by curl_handles_lock curltime_t S3fsCurl::curl_times; curlprogress_t S3fsCurl::curl_progress; -string S3fsCurl::curl_ca_bundle; +std::string S3fsCurl::curl_ca_bundle; mimes_t S3fsCurl::mimeTypes; -string S3fsCurl::userAgent; +std::string S3fsCurl::userAgent; int S3fsCurl::max_parallel_cnt = 5; // default int S3fsCurl::max_multireq = 20; // default off_t S3fsCurl::multipart_size = MULTIPART_SIZE; // default @@ -370,12 +368,12 @@ int S3fsCurl::CurlProgress(void *clientp, double dltotal, double dlnow, double u bool S3fsCurl::InitMimeType(const std::string& strFile) { - string MimeFile; + std::string MimeFile; if(!strFile.empty()){ MimeFile = strFile; }else{ // search default mime.types - string errPaths = DEFAULT_MIME_FILE; + std::string errPaths = DEFAULT_MIME_FILE; struct stat st; if(0 == stat(DEFAULT_MIME_FILE, &st)){ MimeFile = DEFAULT_MIME_FILE; @@ -395,8 +393,8 @@ bool S3fsCurl::InitMimeType(const std::string& strFile) } S3FS_PRN_DBG("Try to load mime types from %s file.", MimeFile.c_str()); - string line; - ifstream MT(MimeFile.c_str()); + std::string line; + std::ifstream MT(MimeFile.c_str()); if(MT.good()){ S3FS_PRN_DBG("The old mime types are cleared to load new mime types."); S3fsCurl::mimeTypes.clear(); @@ -409,11 +407,11 @@ bool S3fsCurl::InitMimeType(const std::string& strFile) continue; } - istringstream tmp(line); - string mimeType; + std::istringstream tmp(line); + std::string mimeType; tmp >> mimeType; while(tmp){ - string ext; + std::string ext; tmp >> ext; if(ext.empty()){ continue; @@ -447,32 +445,32 @@ void S3fsCurl::InitUserAgent() // @param s e.g., "index.html" // @return e.g., "text/html" // -string S3fsCurl::LookupMimeType(const string& name) +std::string S3fsCurl::LookupMimeType(const std::string& name) { if(!name.empty() && name[name.size() - 1] == '/'){ return "application/x-directory"; } - string result("application/octet-stream"); - string::size_type last_pos = name.find_last_of('.'); - string::size_type first_pos = name.find_first_of('.'); - string prefix, ext, ext2; + std::string result("application/octet-stream"); + std::string::size_type last_pos = name.find_last_of('.'); + std::string::size_type first_pos = name.find_first_of('.'); + std::string prefix, ext, ext2; // No dots in name, just return - if(last_pos == string::npos){ + if(last_pos == std::string::npos){ return result; } // extract the last extension - ext = name.substr(1+last_pos, string::npos); + ext = name.substr(1+last_pos, std::string::npos); - if (last_pos != string::npos) { + if (last_pos != std::string::npos) { // one dot was found, now look for another - if (first_pos != string::npos && first_pos < last_pos) { + if (first_pos != std::string::npos && first_pos < last_pos) { prefix = name.substr(0, last_pos); // Now get the second to last file extension - string::size_type next_pos = prefix.find_last_of('.'); - if (next_pos != string::npos) { - ext2 = prefix.substr(1+next_pos, string::npos); + std::string::size_type next_pos = prefix.find_last_of('.'); + if (next_pos != std::string::npos) { + ext2 = prefix.substr(1+next_pos, std::string::npos); } } } @@ -513,7 +511,7 @@ bool S3fsCurl::LocateBundle() char* CURL_CA_BUNDLE = getenv("CURL_CA_BUNDLE"); if(CURL_CA_BUNDLE != NULL) { // check for existence and readability of the file - ifstream BF(CURL_CA_BUNDLE); + std::ifstream BF(CURL_CA_BUNDLE); if(!BF.good()){ S3FS_PRN_ERR("%s: file specified by CURL_CA_BUNDLE environment variable is not readable", program_name.c_str()); return false; @@ -548,7 +546,7 @@ bool S3fsCurl::LocateBundle() // according to the OS. Thus, although we do not need // to check files here, we will only examine some files. // - ifstream BF("/etc/pki/tls/certs/ca-bundle.crt"); + std::ifstream BF("/etc/pki/tls/certs/ca-bundle.crt"); if(BF.good()){ BF.close(); S3fsCurl::curl_ca_bundle.assign("/etc/pki/tls/certs/ca-bundle.crt"); @@ -610,19 +608,19 @@ size_t S3fsCurl::ReadCallback(void* ptr, size_t size, size_t nmemb, void* userp) size_t S3fsCurl::HeaderCallback(void* data, size_t blockSize, size_t numBlocks, void* userPtr) { - headers_t* headers = reinterpret_cast(userPtr); - string header(reinterpret_cast(data), blockSize * numBlocks); - string key; - istringstream ss(header); + headers_t* headers = reinterpret_cast(userPtr); + std::string header(reinterpret_cast(data), blockSize * numBlocks); + std::string key; + std::istringstream ss(header); if(getline(ss, key, ':')){ // Force to lower, only "x-amz" - string lkey = key; + std::string lkey = key; transform(lkey.begin(), lkey.end(), lkey.begin(), static_cast(std::tolower)); if(lkey.compare(0, 5, "x-amz") == 0){ key = lkey; } - string value; + std::string value; getline(ss, value); (*headers)[key] = trim(value); } @@ -763,7 +761,7 @@ storage_class_t S3fsCurl::SetStorageClass(storage_class_t storage_class) return old; } -bool S3fsCurl::PushbackSseKeys(string& onekey) +bool S3fsCurl::PushbackSseKeys(std::string& onekey) { onekey = trim(onekey); if(onekey.empty()){ @@ -773,14 +771,14 @@ bool S3fsCurl::PushbackSseKeys(string& onekey) return false; } // make base64 if the key is short enough, otherwise assume it is already so - string base64_key; - string raw_key; + std::string base64_key; + std::string raw_key; if(onekey.length() > 256 / 8){ char* p_key; size_t keylength; if(NULL != (p_key = (char *)s3fs_decode64(onekey.c_str(), &keylength))) { - raw_key = string(p_key, keylength); + raw_key = std::string(p_key, keylength); base64_key = onekey; delete[] p_key; } else { @@ -801,7 +799,7 @@ bool S3fsCurl::PushbackSseKeys(string& onekey) } // make MD5 - string strMd5; + std::string strMd5; if(!make_md5_from_binary(raw_key.c_str(), raw_key.length(), strMd5)){ S3FS_PRN_ERR("Could not make MD5 from SSE-C keys(%s).", raw_key.c_str()); return false; @@ -840,13 +838,13 @@ bool S3fsCurl::SetSseCKeys(const char* filepath) S3fsCurl::sseckeys.clear(); - ifstream ssefs(filepath); + std::ifstream ssefs(filepath); if(!ssefs.good()){ S3FS_PRN_ERR("Could not open SSE-C keys file(%s).", filepath); return false; } - string line; + std::string line; while(getline(ssefs, line)){ S3fsCurl::PushbackSseKeys(line); } @@ -911,8 +909,8 @@ bool S3fsCurl::LoadEnvSseCKeys() } S3fsCurl::sseckeys.clear(); - istringstream fullkeys(envkeys); - string onekey; + std::istringstream fullkeys(envkeys); + std::string onekey; while(getline(fullkeys, onekey, ':')){ S3fsCurl::PushbackSseKeys(onekey); } @@ -936,7 +934,7 @@ bool S3fsCurl::LoadEnvSseKmsid() // // If md5 is empty, returns first(current) sse key. // -bool S3fsCurl::GetSseKey(string& md5, string& ssekey) +bool S3fsCurl::GetSseKey(std::string& md5, std::string& ssekey) { for(sseckeylist_t::const_iterator iter = S3fsCurl::sseckeys.begin(); iter != S3fsCurl::sseckeys.end(); ++iter){ if(0 == md5.length() || md5 == (*iter).begin()->first){ @@ -948,7 +946,7 @@ bool S3fsCurl::GetSseKey(string& md5, string& ssekey) return false; } -bool S3fsCurl::GetSseKeyMd5(int pos, string& md5) +bool S3fsCurl::GetSseKeyMd5(int pos, std::string& md5) { if(pos < 0){ return false; @@ -1042,9 +1040,9 @@ bool S3fsCurl::SetIsECS(bool flag) return old; } -string S3fsCurl::SetIAMRole(const char* role) +std::string S3fsCurl::SetIAMRole(const char* role) { - string old = S3fsCurl::IAM_role; + std::string old = S3fsCurl::IAM_role; S3fsCurl::IAM_role = role ? role : ""; return old; } @@ -1056,23 +1054,23 @@ size_t S3fsCurl::SetIAMFieldCount(size_t field_count) return old; } -string S3fsCurl::SetIAMCredentialsURL(const char* url) +std::string S3fsCurl::SetIAMCredentialsURL(const char* url) { - string old = S3fsCurl::IAM_cred_url; + std::string old = S3fsCurl::IAM_cred_url; S3fsCurl::IAM_cred_url = url ? url : ""; return old; } -string S3fsCurl::SetIAMTokenField(const char* token_field) +std::string S3fsCurl::SetIAMTokenField(const char* token_field) { - string old = S3fsCurl::IAM_token_field; + std::string old = S3fsCurl::IAM_token_field; S3fsCurl::IAM_token_field = token_field ? token_field : ""; return old; } -string S3fsCurl::SetIAMExpiryField(const char* expiry_field) +std::string S3fsCurl::SetIAMExpiryField(const char* expiry_field) { - string old = S3fsCurl::IAM_expiry_field; + std::string old = S3fsCurl::IAM_expiry_field; S3fsCurl::IAM_expiry_field = expiry_field ? expiry_field : ""; return old; } @@ -1125,8 +1123,8 @@ S3fsCurl* S3fsCurl::UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl) return NULL; } // parse and get part_num, upload_id. - string upload_id; - string part_num_str; + std::string upload_id; + std::string part_num_str; int part_num; off_t tmp_part_num = 0; if(!get_keyword_value(s3fscurl->url, "uploadId", upload_id)){ @@ -1173,8 +1171,8 @@ S3fsCurl* S3fsCurl::CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl) return NULL; } // parse and get part_num, upload_id. - string upload_id; - string part_num_str; + std::string upload_id; + std::string part_num_str; int part_num; off_t tmp_part_num = 0; if(!get_keyword_value(s3fscurl->url, "uploadId", upload_id)){ @@ -1230,7 +1228,7 @@ S3fsCurl* S3fsCurl::MixMultipartPostRetryCallback(S3fsCurl* s3fscurl) int S3fsCurl::ParallelMultipartUploadRequest(const char* tpath, headers_t& meta, int fd) { int result; - string upload_id; + std::string upload_id; struct stat st; int fd2; etaglist_t list; @@ -1320,7 +1318,7 @@ int S3fsCurl::ParallelMultipartUploadRequest(const char* tpath, headers_t& meta, int S3fsCurl::ParallelMixMultipartUploadRequest(const char* tpath, headers_t& meta, int fd, const fdpage_list_t& mixuppages) { int result; - string upload_id; + std::string upload_id; struct stat st; int fd2; etaglist_t list; @@ -1349,10 +1347,10 @@ int S3fsCurl::ParallelMixMultipartUploadRequest(const char* tpath, headers_t& me s3fscurl.DestroyCurlHandle(); // for copy multipart - string srcresource; - string srcurl; + std::string srcresource; + std::string srcurl; MakeUrlResource(get_realpath(tpath).c_str(), srcresource, srcurl); - meta["Content-Type"] = S3fsCurl::LookupMimeType(string(tpath)); + meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(tpath)); meta["x-amz-copy-source"] = srcresource; // Initialize S3fsMultiCurl @@ -1384,11 +1382,11 @@ int S3fsCurl::ParallelMixMultipartUploadRequest(const char* tpath, headers_t& me } }else{ // Multipart copy - ostringstream strrange; + std::ostringstream strrange; strrange << "bytes=" << iter->offset << "-" << (iter->offset + iter->bytes - 1); meta["x-amz-copy-source-range"] = strrange.str(); strrange.str(""); - strrange.clear(stringstream::goodbit); + strrange.clear(std::stringstream::goodbit); s3fscurl_para->b_from = SAFESTRPTR(tpath); s3fscurl_para->b_meta = meta; @@ -1464,7 +1462,7 @@ int S3fsCurl::ParallelGetObjectRequest(const char* tpath, int fd, off_t start, s S3FS_PRN_INFO3("[tpath=%s][fd=%d]", SAFESTRPTR(tpath), fd); sse_type_t ssetype = sse_type_t::SSE_DISABLE; - string ssevalue; + std::string ssevalue; if(!get_object_sse_type(tpath, ssetype, ssevalue)){ S3FS_PRN_WARN("Failed to get SSE type for file(%s).", SAFESTRPTR(tpath)); } @@ -1600,47 +1598,47 @@ bool S3fsCurl::ParseIAMCredentialResponse(const char* response, iamcredmap_t& ke if(!response){ return false; } - istringstream sscred(response); - string oneline; + std::istringstream sscred(response); + std::string oneline; keyval.clear(); while(getline(sscred, oneline, ',')){ - string::size_type pos; - string key; - string val; - if(string::npos != (pos = oneline.find(IAMCRED_ACCESSKEYID))){ + std::string::size_type pos; + std::string key; + std::string val; + if(std::string::npos != (pos = oneline.find(IAMCRED_ACCESSKEYID))){ key = IAMCRED_ACCESSKEYID; - }else if(string::npos != (pos = oneline.find(IAMCRED_SECRETACCESSKEY))){ + }else if(std::string::npos != (pos = oneline.find(IAMCRED_SECRETACCESSKEY))){ key = IAMCRED_SECRETACCESSKEY; - }else if(string::npos != (pos = oneline.find(S3fsCurl::IAM_token_field))){ + }else if(std::string::npos != (pos = oneline.find(S3fsCurl::IAM_token_field))){ key = S3fsCurl::IAM_token_field; - }else if(string::npos != (pos = oneline.find(S3fsCurl::IAM_expiry_field))){ + }else if(std::string::npos != (pos = oneline.find(S3fsCurl::IAM_expiry_field))){ key = S3fsCurl::IAM_expiry_field; - }else if(string::npos != (pos = oneline.find(IAMCRED_ROLEARN))){ + }else if(std::string::npos != (pos = oneline.find(IAMCRED_ROLEARN))){ key = IAMCRED_ROLEARN; }else{ continue; } - if(string::npos == (pos = oneline.find(':', pos + key.length()))){ + if(std::string::npos == (pos = oneline.find(':', pos + key.length()))){ continue; } if(S3fsCurl::is_ibm_iam_auth && key == S3fsCurl::IAM_expiry_field){ // parse integer value - if(string::npos == (pos = oneline.find_first_of("0123456789", pos))){ + if(std::string::npos == (pos = oneline.find_first_of("0123456789", pos))){ continue; } oneline = oneline.substr(pos); - if(string::npos == (pos = oneline.find_last_of("0123456789"))){ + if(std::string::npos == (pos = oneline.find_last_of("0123456789"))){ continue; } val = oneline.substr(0, pos+1); }else{ - // parse string value (starts and ends with quotes) - if(string::npos == (pos = oneline.find('\"', pos))){ + // parse std::string value (starts and ends with quotes) + if(std::string::npos == (pos = oneline.find('\"', pos))){ continue; } oneline = oneline.substr(pos + sizeof(char)); - if(string::npos == (pos = oneline.find('\"'))){ + if(std::string::npos == (pos = oneline.find('\"'))){ continue; } val = oneline.substr(0, pos); @@ -1664,17 +1662,17 @@ bool S3fsCurl::SetIAMCredentials(const char* response) return false; } - S3fsCurl::AWSAccessToken = keyval[string(S3fsCurl::IAM_token_field)]; + S3fsCurl::AWSAccessToken = keyval[std::string(S3fsCurl::IAM_token_field)]; if(S3fsCurl::is_ibm_iam_auth){ off_t tmp_expire = 0; - if(!try_strtoofft(keyval[string(S3fsCurl::IAM_expiry_field)].c_str(), tmp_expire, /*base=*/ 10)){ + if(!try_strtoofft(keyval[std::string(S3fsCurl::IAM_expiry_field)].c_str(), tmp_expire, /*base=*/ 10)){ return false; } S3fsCurl::AWSAccessTokenExpire = static_cast(tmp_expire); }else{ - S3fsCurl::AWSAccessKeyId = keyval[string(IAMCRED_ACCESSKEYID)]; - S3fsCurl::AWSSecretAccessKey = keyval[string(IAMCRED_SECRETACCESSKEY)]; + S3fsCurl::AWSAccessKeyId = keyval[std::string(IAMCRED_ACCESSKEYID)]; + S3fsCurl::AWSSecretAccessKey = keyval[std::string(IAMCRED_SECRETACCESSKEY)]; S3fsCurl::AWSAccessTokenExpire = cvtIAMExpireStringToTime(keyval[S3fsCurl::IAM_expiry_field].c_str()); } return true; @@ -1696,7 +1694,7 @@ bool S3fsCurl::CheckIAMCredentialUpdate() return true; } -bool S3fsCurl::ParseIAMRoleFromMetaDataResponse(const char* response, string& rolename) +bool S3fsCurl::ParseIAMRoleFromMetaDataResponse(const char* response, std::string& rolename) { if(!response){ return false; @@ -1706,8 +1704,8 @@ bool S3fsCurl::ParseIAMRoleFromMetaDataResponse(const char* response, string& ro // // myrolename // - istringstream ssrole(response); - string oneline; + std::istringstream ssrole(response); + std::string oneline; if (getline(ssrole, oneline, '\n')){ rolename = oneline; return !rolename.empty(); @@ -1719,7 +1717,7 @@ bool S3fsCurl::SetIAMRoleFromMetaData(const char* response) { S3FS_PRN_INFO3("IAM role name response = \"%s\"", response); - string rolename; + std::string rolename; if(!S3fsCurl::ParseIAMRoleFromMetaDataResponse(response, rolename)){ return false; @@ -2355,7 +2353,7 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/) S3FS_PRN_ERR("### CURLE_PEER_FAILED_VERIFICATION"); first_pos = bucket.find_first_of("."); - if(first_pos != string::npos){ + if(first_pos != std::string::npos){ S3FS_PRN_INFO("curl returned a CURL_PEER_FAILED_VERIFICATION error"); S3FS_PRN_INFO("security issue found: buckets with periods in their name are incompatible with http"); S3FS_PRN_INFO("This check can be over-ridden by using the -o ssl_verify_hostname=0"); @@ -2426,10 +2424,10 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/) // @param date e.g., get_date_rfc850() // @param resource e.g., "/pub" // -string S3fsCurl::CalcSignatureV2(const string& method, const string& strMD5, const string& content_type, const string& date, const string& resource) +std::string S3fsCurl::CalcSignatureV2(const std::string& method, const std::string& strMD5, const std::string& content_type, const std::string& date, const std::string& resource) { - string Signature; - string StringToSign; + std::string Signature; + std::string StringToSign; if(!S3fsCurl::IAM_role.empty() || S3fsCurl::is_ecs || S3fsCurl::is_use_session_token){ requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-security-token", S3fsCurl::AWSAccessToken.c_str()); @@ -2454,7 +2452,7 @@ string S3fsCurl::CalcSignatureV2(const string& method, const string& strMD5, con char* base64; if(NULL == (base64 = s3fs_base64(md, md_len))){ delete[] md; - return string(""); // ENOMEM + return std::string(""); // ENOMEM } delete[] md; @@ -2464,10 +2462,10 @@ string S3fsCurl::CalcSignatureV2(const string& method, const string& strMD5, con return Signature; } -string S3fsCurl::CalcSignature(const string& method, const string& canonical_uri, const string& query_string, const string& strdate, const string& payload_hash, const string& date8601) +std::string S3fsCurl::CalcSignature(const std::string& method, const std::string& canonical_uri, const std::string& query_string, const std::string& strdate, const std::string& payload_hash, const std::string& date8601) { - string Signature, StringCQ, StringToSign; - string uriencode; + std::string Signature, StringCQ, StringToSign; + std::string uriencode; if(!S3fsCurl::IAM_role.empty() || S3fsCurl::is_ecs || S3fsCurl::is_use_session_token){ requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-security-token", S3fsCurl::AWSAccessToken.c_str()); @@ -2540,8 +2538,8 @@ string S3fsCurl::CalcSignature(const string& method, const string& canonical_uri void S3fsCurl::insertV4Headers() { - string server_path = type == REQTYPE_LISTBUCKET ? "/" : path; - string payload_hash; + std::string server_path = type == REQTYPE_LISTBUCKET ? "/" : path; + std::string payload_hash; switch (type) { case REQTYPE_PUT: payload_hash = s3fs_sha256sum(b_infile == NULL ? -1 : fileno(b_infile), 0, -1); @@ -2571,11 +2569,11 @@ void S3fsCurl::insertV4Headers() } S3FS_PRN_INFO3("computing signature [%s] [%s] [%s] [%s]", op.c_str(), server_path.c_str(), query_string.c_str(), payload_hash.c_str()); - string strdate; - string date8601; + std::string strdate; + std::string date8601; get_date_sigv3(strdate, date8601); - string contentSHA256 = payload_hash.empty() ? empty_payload_hash : payload_hash; + std::string contentSHA256 = payload_hash.empty() ? empty_payload_hash : payload_hash; const std::string realpath = pathrequeststyle ? "/" + bucket + server_path : server_path; //string canonical_headers, signed_headers; @@ -2588,31 +2586,31 @@ void S3fsCurl::insertV4Headers() } if(!S3fsCurl::IsPublicBucket()){ - string Signature = CalcSignature(op, realpath, query_string + (type == REQTYPE_PREMULTIPOST || type == REQTYPE_MULTILIST ? "=" : ""), strdate, contentSHA256, date8601); - string auth = "AWS4-HMAC-SHA256 Credential=" + AWSAccessKeyId + "/" + strdate + "/" + endpoint + "/s3/aws4_request, SignedHeaders=" + get_sorted_header_keys(requestHeaders) + ", Signature=" + Signature; + std::string Signature = CalcSignature(op, realpath, query_string + (type == REQTYPE_PREMULTIPOST || type == REQTYPE_MULTILIST ? "=" : ""), strdate, contentSHA256, date8601); + std::string auth = "AWS4-HMAC-SHA256 Credential=" + AWSAccessKeyId + "/" + strdate + "/" + endpoint + "/s3/aws4_request, SignedHeaders=" + get_sorted_header_keys(requestHeaders) + ", Signature=" + Signature; requestHeaders = curl_slist_sort_insert(requestHeaders, "Authorization", auth.c_str()); } } void S3fsCurl::insertV2Headers() { - string resource; - string turl; - string server_path = type == REQTYPE_LISTBUCKET ? "/" : path; + std::string resource; + std::string turl; + std::string server_path = type == REQTYPE_LISTBUCKET ? "/" : path; MakeUrlResource(server_path.c_str(), resource, turl); if(!query_string.empty() && type != REQTYPE_LISTBUCKET){ resource += "?" + query_string; } - string date = get_date_rfc850(); + std::string date = get_date_rfc850(); requestHeaders = curl_slist_sort_insert(requestHeaders, "Date", date.c_str()); if(op != "PUT" && op != "POST"){ requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", NULL); } if(!S3fsCurl::IsPublicBucket()){ - string Signature = CalcSignatureV2(op, get_header_value(requestHeaders, "Content-MD5"), get_header_value(requestHeaders, "Content-Type"), date, resource); - requestHeaders = curl_slist_sort_insert(requestHeaders, "Authorization", string("AWS " + AWSAccessKeyId + ":" + Signature).c_str()); + std::string Signature = CalcSignatureV2(op, get_header_value(requestHeaders, "Content-MD5"), get_header_value(requestHeaders, "Content-Type"), date, resource); + requestHeaders = curl_slist_sort_insert(requestHeaders, "Authorization", std::string("AWS " + AWSAccessKeyId + ":" + Signature).c_str()); } } @@ -2652,8 +2650,8 @@ int S3fsCurl::DeleteRequest(const char* tpath) if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); url = prepare_url(turl.c_str()); @@ -2695,18 +2693,18 @@ int S3fsCurl::GetIAMCredentials() // url if(is_ecs){ - url = string(S3fsCurl::IAM_cred_url) + std::getenv(ECS_IAM_ENV_VAR.c_str()); + url = std::string(S3fsCurl::IAM_cred_url) + std::getenv(ECS_IAM_ENV_VAR.c_str()); }else{ - url = string(S3fsCurl::IAM_cred_url) + S3fsCurl::IAM_role; + url = std::string(S3fsCurl::IAM_cred_url) + S3fsCurl::IAM_role; } requestHeaders = NULL; responseHeaders.clear(); bodydata.Clear(); - string postContent; + std::string postContent; if(S3fsCurl::is_ibm_iam_auth){ - url = string(S3fsCurl::IAM_cred_url); + url = std::string(S3fsCurl::IAM_cred_url); // make contents postContent += "grant_type=urn:ibm:params:oauth:grant-type:apikey"; @@ -2759,7 +2757,7 @@ bool S3fsCurl::LoadIAMRoleFromMetaData() } // url - url = string(S3fsCurl::IAM_cred_url); + url = std::string(S3fsCurl::IAM_cred_url); requestHeaders = NULL; responseHeaders.clear(); bodydata.Clear(); @@ -2781,7 +2779,7 @@ bool S3fsCurl::LoadIAMRoleFromMetaData() return (0 == result); } -bool S3fsCurl::AddSseRequestHead(sse_type_t ssetype, string& ssevalue, bool is_only_c, bool is_copy) +bool S3fsCurl::AddSseRequestHead(sse_type_t ssetype, std::string& ssevalue, bool is_only_c, bool is_copy) { switch(ssetype){ case sse_type_t::SSE_DISABLE: @@ -2793,7 +2791,7 @@ bool S3fsCurl::AddSseRequestHead(sse_type_t ssetype, string& ssevalue, bool is_o return true; case sse_type_t::SSE_C: { - string sseckey; + std::string sseckey; if(S3fsCurl::GetSseKey(ssevalue, sseckey)){ if(is_copy){ requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-copy-source-server-side-encryption-customer-algorithm", "AES256"); @@ -2838,8 +2836,8 @@ bool S3fsCurl::PreHeadRequest(const char* tpath, const char* bpath, const char* if(!tpath){ return false; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); // libcurl 7.17 does deep copy of url, deep copy "stable" url @@ -2852,7 +2850,7 @@ bool S3fsCurl::PreHeadRequest(const char* tpath, const char* bpath, const char* // requestHeaders if(0 <= ssekey_pos){ - string md5; + std::string md5; if(!S3fsCurl::GetSseKeyMd5(ssekey_pos, md5) || !AddSseRequestHead(sse_type_t::SSE_C, md5, true, false)){ S3FS_PRN_ERR("Failed to set SSE-C headers for sse-c key pos(%d)(=md5(%s)).", ssekey_pos, md5.c_str()); return false; @@ -2903,8 +2901,8 @@ int S3fsCurl::HeadRequest(const char* tpath, headers_t& meta) // fixme: clean this up. meta.clear(); for(headers_t::iterator iter = responseHeaders.begin(); iter != responseHeaders.end(); ++iter){ - string key = lower(iter->first); - string value = iter->second; + std::string key = lower(iter->first); + std::string value = iter->second; if(key == "content-type"){ meta[iter->first] = value; }else if(key == "content-length"){ @@ -2930,8 +2928,8 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy) if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); url = prepare_url(turl.c_str()); @@ -2940,13 +2938,13 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy) responseHeaders.clear(); bodydata.Clear(); - string contype = S3fsCurl::LookupMimeType(string(tpath)); + std::string contype = S3fsCurl::LookupMimeType(std::string(tpath)); requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str()); // Make request headers for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){ - string key = lower(iter->first); - string value = iter->second; + std::string key = lower(iter->first); + std::string value = iter->second; if(key.substr(0, 9) == "x-amz-acl"){ // not set value, but after set it. }else if(key.substr(0, 10) == "x-amz-meta"){ @@ -2982,7 +2980,7 @@ int S3fsCurl::PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy) } // SSE if(!is_copy){ - string ssevalue; + std::string ssevalue; if(!AddSseRequestHead(S3fsCurl::GetSseType(), ssevalue, false, false)){ S3FS_PRN_WARN("Failed to set SSE header, but continue..."); } @@ -3063,8 +3061,8 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) } return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); url = prepare_url(turl.c_str()); @@ -3074,18 +3072,18 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) bodydata.Clear(); // Make request headers - string strMD5; + std::string strMD5; if(-1 != fd && S3fsCurl::is_content_md5){ strMD5 = s3fs_get_content_md5(fd); requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-MD5", strMD5.c_str()); } - string contype = S3fsCurl::LookupMimeType(string(tpath)); + std::string contype = S3fsCurl::LookupMimeType(std::string(tpath)); requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str()); for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){ - string key = lower(iter->first); - string value = iter->second; + std::string key = lower(iter->first); + std::string value = iter->second; if(key.substr(0, 9) == "x-amz-acl"){ // not set value, but after set it. }else if(key.substr(0, 10) == "x-amz-meta"){ @@ -3106,7 +3104,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) requestHeaders = curl_slist_sort_insert(requestHeaders, "x-amz-storage-class", GetStorageClass().str()); } // SSE - string ssevalue; + std::string ssevalue; if(!AddSseRequestHead(S3fsCurl::GetSseType(), ssevalue, false, false)){ S3FS_PRN_WARN("Failed to set SSE header, but continue..."); } @@ -3141,7 +3139,7 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) return result; } -int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_t size, sse_type_t ssetype, string& ssevalue) +int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_t size, sse_type_t ssetype, std::string& ssevalue) { S3FS_PRN_INFO3("[tpath=%s][start=%lld][size=%lld]", SAFESTRPTR(tpath), static_cast(start), static_cast(size)); @@ -3149,8 +3147,8 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); url = prepare_url(turl.c_str()); @@ -3159,7 +3157,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_ responseHeaders.clear(); if(-1 != start && 0 < size){ - string range = "bytes="; + std::string range = "bytes="; range += str(start); range += "-"; range += str(start + size - 1); @@ -3201,7 +3199,7 @@ int S3fsCurl::GetObjectRequest(const char* tpath, int fd, off_t start, ssize_t s return -1; } sse_type_t ssetype = sse_type_t::SSE_DISABLE; - string ssevalue; + std::string ssevalue; if(!get_object_sse_type(tpath, ssetype, ssevalue)){ S3FS_PRN_WARN("Failed to get SSE type for file(%s).", SAFESTRPTR(tpath)); } @@ -3229,8 +3227,8 @@ int S3fsCurl::CheckBucket() if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath("/").c_str(), resource, turl); url = prepare_url(turl.c_str()); @@ -3265,8 +3263,8 @@ int S3fsCurl::ListBucketRequest(const char* tpath, const char* query) if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource("", resource, turl); // NOTICE: path is "". if(query){ turl += "?"; @@ -3304,7 +3302,7 @@ int S3fsCurl::ListBucketRequest(const char* tpath, const char* query) // Date: Mon, 1 Nov 2010 20:34:56 GMT // Authorization: AWS VGhpcyBtZXNzYWdlIHNpZ25lZCBieSBlbHZpbmc= // -int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string& upload_id, bool is_copy) +int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, std::string& upload_id, bool is_copy) { S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath)); @@ -3314,8 +3312,8 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); query_string = "uploads"; @@ -3326,11 +3324,11 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string bodydata.Clear(); responseHeaders.clear(); - string contype = S3fsCurl::LookupMimeType(string(tpath)); + std::string contype = S3fsCurl::LookupMimeType(std::string(tpath)); for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){ - string key = lower(iter->first); - string value = iter->second; + std::string key = lower(iter->first); + std::string value = iter->second; if(key.substr(0, 9) == "x-amz-acl"){ // not set value, but after set it. }else if(key.substr(0, 10) == "x-amz-meta"){ @@ -3363,7 +3361,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string } // SSE if(!is_copy){ - string ssevalue; + std::string ssevalue; if(!AddSseRequestHead(S3fsCurl::GetSseType(), ssevalue, false, false)){ S3FS_PRN_WARN("Failed to set SSE header, but continue..."); } @@ -3404,7 +3402,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string return 0; } -int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const string& upload_id, etaglist_t& parts) +int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string& upload_id, etaglist_t& parts) { S3FS_PRN_INFO3("[tpath=%s][parts=%zu]", SAFESTRPTR(tpath), parts.size()); @@ -3413,7 +3411,7 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const string& uplo } // make contents - string postContent; + std::string postContent; postContent += "\n"; for(int cnt = 0; cnt < (int)parts.size(); cnt++){ if(0 == parts[cnt].length()){ @@ -3436,8 +3434,8 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const string& uplo if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); query_string = "uploadId=" + upload_id; @@ -3447,7 +3445,7 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const string& uplo requestHeaders = NULL; bodydata.Clear(); responseHeaders.clear(); - string contype = "application/xml"; + std::string contype = "application/xml"; requestHeaders = curl_slist_sort_insert(requestHeaders, "Accept", NULL); requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str()); @@ -3476,15 +3474,15 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const string& uplo return result; } -int S3fsCurl::MultipartListRequest(string& body) +int S3fsCurl::MultipartListRequest(std::string& body) { S3FS_PRN_INFO3("list request(multipart)"); if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; path = get_realpath("/"); MakeUrlResource(path.c_str(), resource, turl); @@ -3517,7 +3515,7 @@ int S3fsCurl::MultipartListRequest(string& body) return result; } -int S3fsCurl::AbortMultipartUpload(const char* tpath, const string& upload_id) +int S3fsCurl::AbortMultipartUpload(const char* tpath, const std::string& upload_id) { S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath)); @@ -3527,8 +3525,8 @@ int S3fsCurl::AbortMultipartUpload(const char* tpath, const string& upload_id) if(!CreateCurlHandle()){ return -1; } - string resource; - string turl; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); query_string = "uploadId=" + upload_id; @@ -3562,7 +3560,7 @@ int S3fsCurl::AbortMultipartUpload(const char* tpath, const string& upload_id) // Content-MD5: pUNXr/BjKK5G2UKvaRRrOA== // Authorization: AWS VGhpcyBtZXNzYWdlIHNpZ25lZGGieSRlbHZpbmc= // -int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const string& upload_id) +int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id) { S3FS_PRN_INFO3("[tpath=%s][start=%lld][size=%lld][part=%d]", SAFESTRPTR(tpath), static_cast(partdata.startpos), static_cast(partdata.size), part_num); @@ -3588,9 +3586,9 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st // make request query_string = "partNumber=" + str(part_num) + "&uploadId=" + upload_id; - string urlargs = "?" + query_string; - string resource; - string turl; + std::string urlargs = "?" + query_string; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(tpath).c_str(), resource, turl); turl += urlargs; @@ -3602,7 +3600,7 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st // SSE if(sse_type_t::SSE_C == S3fsCurl::GetSseType()){ - string ssevalue; + std::string ssevalue; if(!AddSseRequestHead(S3fsCurl::GetSseType(), ssevalue, false, false)){ S3FS_PRN_WARN("Failed to set SSE header, but continue..."); } @@ -3619,7 +3617,7 @@ int S3fsCurl::UploadMultipartPostSetup(const char* tpath, int part_num, const st return 0; } -int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, const string& upload_id) +int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, const std::string& upload_id) { int result; @@ -3648,17 +3646,17 @@ int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, const return result; } -int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_num, const string& upload_id, headers_t& meta) +int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_num, const std::string& upload_id, headers_t& meta) { S3FS_PRN_INFO3("[from=%s][to=%s][part=%d]", SAFESTRPTR(from), SAFESTRPTR(to), part_num); if(!from || !to){ return -1; } - query_string = "partNumber=" + str(part_num) + "&uploadId=" + upload_id; - string urlargs = "?" + query_string; - string resource; - string turl; + query_string = "partNumber=" + str(part_num) + "&uploadId=" + upload_id; + std::string urlargs = "?" + query_string; + std::string resource; + std::string turl; MakeUrlResource(get_realpath(to).c_str(), resource, turl); turl += urlargs; @@ -3669,13 +3667,13 @@ int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_ bodydata.Clear(); headdata.Clear(); - string contype = S3fsCurl::LookupMimeType(string(to)); + std::string contype = S3fsCurl::LookupMimeType(std::string(to)); requestHeaders = curl_slist_sort_insert(requestHeaders, "Content-Type", contype.c_str()); // Make request headers for(headers_t::iterator iter = meta.begin(); iter != meta.end(); ++iter){ - string key = lower(iter->first); - string value = iter->second; + std::string key = lower(iter->first); + std::string value = iter->second; if(key == "x-amz-copy-source"){ requestHeaders = curl_slist_sort_insert(requestHeaders, iter->first.c_str(), value.c_str()); }else if(key == "x-amz-copy-source-range"){ @@ -3759,11 +3757,11 @@ bool S3fsCurl::MixMultipartPostComplete() int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& meta, bool is_copy) { int result; - string upload_id; + std::string upload_id; off_t chunk; off_t bytes_remaining; etaglist_t list; - ostringstream strrange; + std::ostringstream strrange; S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath)); @@ -3783,7 +3781,7 @@ int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& met strrange << "bytes=" << (size - bytes_remaining) << "-" << (size - bytes_remaining + chunk - 1); meta["x-amz-copy-source-range"] = strrange.str(); strrange.str(""); - strrange.clear(stringstream::goodbit); + strrange.clear(std::stringstream::goodbit); // s3fscurl sub object S3fsCurl* s3fscurl_para = new S3fsCurl(true); @@ -3828,7 +3826,7 @@ int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& met int S3fsCurl::MultipartUploadRequest(const char* tpath, headers_t& meta, int fd, bool is_copy) { int result; - string upload_id; + std::string upload_id; struct stat st; int fd2; etaglist_t list; @@ -3886,7 +3884,7 @@ int S3fsCurl::MultipartUploadRequest(const char* tpath, headers_t& meta, int fd, return 0; } -int S3fsCurl::MultipartUploadRequest(const string& upload_id, const char* tpath, int fd, off_t offset, off_t size, etaglist_t& list) +int S3fsCurl::MultipartUploadRequest(const std::string& upload_id, const char* tpath, int fd, off_t offset, off_t size, etaglist_t& list) { S3FS_PRN_INFO3("[upload_id=%s][tpath=%s][fd=%d][offset=%lld][size=%lld]", upload_id.c_str(), SAFESTRPTR(tpath), fd, static_cast(offset), static_cast(size)); @@ -3924,19 +3922,19 @@ int S3fsCurl::MultipartUploadRequest(const string& upload_id, const char* tpath, int S3fsCurl::MultipartRenameRequest(const char* from, const char* to, headers_t& meta, off_t size) { int result; - string upload_id; + std::string upload_id; off_t chunk; off_t bytes_remaining; etaglist_t list; - ostringstream strrange; + std::ostringstream strrange; S3FS_PRN_INFO3("[from=%s][to=%s]", SAFESTRPTR(from), SAFESTRPTR(to)); - string srcresource; - string srcurl; + std::string srcresource; + std::string srcurl; MakeUrlResource(get_realpath(from).c_str(), srcresource, srcurl); - meta["Content-Type"] = S3fsCurl::LookupMimeType(string(to)); + meta["Content-Type"] = S3fsCurl::LookupMimeType(std::string(to)); meta["x-amz-copy-source"] = srcresource; if(0 != (result = PreMultipartPostRequest(to, meta, upload_id, true))){ @@ -3955,7 +3953,7 @@ int S3fsCurl::MultipartRenameRequest(const char* from, const char* to, headers_t strrange << "bytes=" << (size - bytes_remaining) << "-" << (size - bytes_remaining + chunk - 1); meta["x-amz-copy-source-range"] = strrange.str(); strrange.str(""); - strrange.clear(stringstream::goodbit); + strrange.clear(std::stringstream::goodbit); // s3fscurl sub object S3fsCurl* s3fscurl_para = new S3fsCurl(true); diff --git a/src/curl_handlerpool.cpp b/src/curl_handlerpool.cpp index 729ec85..ad53fe4 100644 --- a/src/curl_handlerpool.cpp +++ b/src/curl_handlerpool.cpp @@ -26,8 +26,6 @@ #include "curl_handlerpool.h" #include "autolock.h" -using namespace std; - //------------------------------------------------------------------- // Class CurlHandlerPool //------------------------------------------------------------------- diff --git a/src/curl_multi.cpp b/src/curl_multi.cpp index 8a71495..fe6251a 100644 --- a/src/curl_multi.cpp +++ b/src/curl_multi.cpp @@ -28,8 +28,6 @@ #include "curl.h" #include "autolock.h" -using namespace std; - //------------------------------------------------------------------- // Class S3fsMultiCurl //------------------------------------------------------------------- diff --git a/src/curl_util.cpp b/src/curl_util.cpp index 3ce656f..32fd972 100644 --- a/src/curl_util.cpp +++ b/src/curl_util.cpp @@ -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); diff --git a/src/fdcache.cpp b/src/fdcache.cpp index 1628050..928399b 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -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; diff --git a/src/fdcache_entity.cpp b/src/fdcache_entity.cpp index ba58a5f..7b01dea 100644 --- a/src/fdcache_entity.cpp +++ b/src/fdcache_entity.cpp @@ -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(sizeof(bytes)), size)); + memset(bytes, byte, std::min(static_cast(sizeof(bytes)), size)); for(off_t total = 0, onewrote = 0; total < size; total += onewrote){ - if(-1 == (onewrote = pwrite(fd, bytes, min(static_cast(sizeof(bytes)), size - total), start + total))){ + if(-1 == (onewrote = pwrite(fd, bytes, std::min(static_cast(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(iter->bytes); totalread += oneread){ int upload_fd = fd; off_t offset = iter->offset + totalread; - oneread = min(static_cast(iter->bytes) - totalread, S3fsCurl::GetMultipartSize()); + oneread = std::min(static_cast(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(size) < pagelist.Size()){ - ssize_t prefetch_max_size = max(static_cast(size), S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount()); + ssize_t prefetch_max_size = std::max(static_cast(size), S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount()); if(start + prefetch_max_size < pagelist.Size()){ load_size = prefetch_max_size; diff --git a/src/fdcache_page.cpp b/src/fdcache_page.cpp index 6e56500..d558d66 100644 --- a/src/fdcache_page.cpp +++ b/src/fdcache_page.cpp @@ -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; diff --git a/src/fdcache_stat.cpp b/src/fdcache_stat.cpp index e27e94a..dfb8071 100644 --- a/src/fdcache_stat.cpp +++ b/src/fdcache_stat.cpp @@ -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; diff --git a/src/gnutls_auth.cpp b/src/gnutls_auth.cpp index e8e46d5..cd2b931 100644 --- a/src/gnutls_auth.cpp +++ b/src/gnutls_auth.cpp @@ -42,8 +42,6 @@ #include "s3fs.h" #include "s3fs_auth.h" -using namespace std; - //------------------------------------------------------------------- // Utility Function for version //------------------------------------------------------------------- diff --git a/src/metaheader.cpp b/src/metaheader.cpp index b835950..15fa898 100644 --- a/src/metaheader.cpp +++ b/src/metaheader.cpp @@ -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"){ diff --git a/src/mpu_util.cpp b/src/mpu_util.cpp index d3ae9b4..d4ea0a6 100644 --- a/src/mpu_util.cpp +++ b/src/mpu_util.cpp @@ -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; diff --git a/src/nss_auth.cpp b/src/nss_auth.cpp index 8657281..5fba304 100644 --- a/src/nss_auth.cpp +++ b/src/nss_auth.cpp @@ -38,8 +38,6 @@ #include "s3fs.h" #include "s3fs_auth.h" -using namespace std; - //------------------------------------------------------------------- // Utility Function for version //------------------------------------------------------------------- diff --git a/src/openssl_auth.cpp b/src/openssl_auth.cpp index e6516aa..40ff8a9 100644 --- a/src/openssl_auth.cpp +++ b/src/openssl_auth.cpp @@ -42,8 +42,6 @@ #include "s3fs.h" #include "s3fs_auth.h" -using namespace std; - //------------------------------------------------------------------- // Utility Function for version //------------------------------------------------------------------- diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 3ba08d6..9e8fafb 100644 --- a/src/s3fs.cpp +++ b/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(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); } diff --git a/src/s3fs_help.cpp b/src/s3fs_help.cpp index 2c4c3eb..1c0836e 100644 --- a/src/s3fs_help.cpp +++ b/src/s3fs_help.cpp @@ -28,8 +28,6 @@ #include "s3fs_help.h" #include "s3fs_auth.h" -using namespace std; - //------------------------------------------------------------------- // Contents //------------------------------------------------------------------- diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index 7ccaa78..24c8e86 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -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); diff --git a/src/s3fs_xml.cpp b/src/s3fs_xml.cpp index f077d7f..8847eea 100644 --- a/src/s3fs_xml.cpp +++ b/src/s3fs_xml.cpp @@ -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 , 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(cur_node->name)); + // std::string cur_node_name(reinterpret_cast(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(cur_node->name); + std::string elementName = reinterpret_cast(cur_node->name); // For DEBUG // printf("elementName: %s\n", elementName.c_str()); diff --git a/src/s3objlist.cpp b/src/s3objlist.cpp index 28602a6..84ecbd0 100644 --- a/src/s3objlist.cpp +++ b/src/s3objlist.cpp @@ -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 += "/"; } diff --git a/src/sighandlers.cpp b/src/sighandlers.cpp index 82ebf51..7f762ed 100644 --- a/src/sighandlers.cpp +++ b/src/sighandlers.cpp @@ -28,8 +28,6 @@ #include "sighandlers.h" #include "fdcache.h" -using namespace std; - //------------------------------------------------------------------- // Class S3fsSignals //------------------------------------------------------------------- diff --git a/src/string_util.cpp b/src/string_util.cpp index b6dd742..2dfd367 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -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; } diff --git a/src/test_string_util.cpp b/src/test_string_util.cpp index a67d8e8..b65bbbc 100644 --- a/src/test_string_util.cpp +++ b/src/test_string_util.cpp @@ -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;