本文整理汇总了C++中std::tstring::rfind方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::rfind方法的具体用法?C++ tstring::rfind怎么用?C++ tstring::rfind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tstring
的用法示例。
在下文中一共展示了tstring::rfind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_url
bool save_url(HANDLE hNetlib,const std::string &url,const std::tstring &filename)
{
NETLIBHTTPREQUEST req = {sizeof(req)};
req.requestType = REQUEST_GET;
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
req.szUrl = const_cast<char*>(url.c_str());
NETLIBHTTPREQUEST *resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
reinterpret_cast<WPARAM>(hNetlib), reinterpret_cast<LPARAM>(&req)));
if (resp)
{
bool success = (resp->resultCode == 200);
if (success)
{
// Create folder if necessary
std::tstring dir = filename.substr(0,filename.rfind('\\'));
if( _taccess(dir.c_str(),0))
CreateDirectoryTreeT(dir.c_str());
// Write to file
FILE *f = _tfopen(filename.c_str(), _T("wb"));
fwrite(resp->pData,1,resp->dataLength,f);
fclose(f);
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)resp);
return success;
}
else
return false;
}
示例2: GetFileExtension
std::tstring GetFileExtension(const std::tstring& fileName)
{
size_t extensionPosition = fileName.rfind(_T('.'));
if(0 < extensionPosition)
return fileName.substr(extensionPosition + 1);
return _T("");
}
示例3: GetFilenameWithoutExtension
std::tstring GetFilenameWithoutExtension(const std::tstring& fileName)
{
size_t extensionPosition = fileName.rfind(_T('.'));
if(0 < extensionPosition)
return fileName.substr(0, extensionPosition);
return fileName;
}
示例4: save_url
bool facebook_client::save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc)
{
NETLIBHTTPREQUEST req = {sizeof(req)};
NETLIBHTTPREQUEST *resp;
req.requestType = REQUEST_GET;
req.szUrl = const_cast<char*>(url.c_str());
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT | NLHRF_NODUMP;
req.nlc = nlc;
resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
reinterpret_cast<WPARAM>(this->parent->m_hNetlibUser), reinterpret_cast<LPARAM>(&req)));
bool ret = false;
if (resp) {
nlc = resp->nlc;
parent->debugLogA("@@@@@ Saving avatar URL %s to path %s", url.c_str(), _T2A(filename.c_str()));
// Create folder if necessary
std::tstring dir = filename.substr(0,filename.rfind('\\'));
if (_taccess(dir.c_str(), 0))
CreateDirectoryTreeT(dir.c_str());
// Write to file
FILE *f = _tfopen(filename.c_str(), _T("wb"));
if (f != NULL) {
fwrite(resp->pData,1,resp->dataLength,f);
fclose(f);
ret = _taccess(filename.c_str(), 0) == 0;
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
} else {
nlc = NULL;
}
return ret;
}