当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::find_last_of方法代码示例

本文整理汇总了C++中wstring::find_last_of方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::find_last_of方法的具体用法?C++ wstring::find_last_of怎么用?C++ wstring::find_last_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wstring的用法示例。


在下文中一共展示了wstring::find_last_of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TrimFilePathW

bool TrimFilePathW(wstring& strPath)
{
    int pos = strPath.find_last_of(L'\\');
    if (wstring::npos == pos)
    {
        return false;
    }
    int count = strPath.size() - pos;
    strPath = strPath.substr(strPath.find_last_of(L'\\') + 1, count);
    return true;
}
开发者ID:wp4398151,项目名称:TestProjectJar,代码行数:11,代码来源:UtilHelper.cpp

示例2: find

//可同时处理目录和文件:path可以是路径,也可以是文件名,或者文件通配符
wstring find(wstring path,bool cursive)
{ 
     //取路径名最后一个"//"之前的部分,包括"//"
	replace_allW(path,L"\\",L"/");
	UINT index=path.find_last_of('/');
	if(index+1==path.length()){
		path.append(L"*.*");
	}
    wstring prefix=path.substr(0,path.find_last_of('/')+1);

    WIN32_FIND_DATA FindFileData;
    HANDLE hFind=::FindFirstFile(path.data(),&FindFileData);
	std::wstringstream ss;
    if(INVALID_HANDLE_VALUE == hFind)
    {
       ss<<L"[]";
	   FindClose(hFind);
	   return ss.str();
    }
	else{
		ss<<L"[";
	}
    while(TRUE)
    {
		bool flag=false;;
      //目录
        if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            //不是当前目录,也不是父目录
            if(cursive&&FindFileData.cFileName[0]!='.')
            {
				wstring temp=prefix+FindFileData.cFileName;
				ss<<L"{\"name\":\""<<FindFileData.cFileName<<L"\",\"list\":"<<find(temp+L"/*.*",cursive).data()<<L"}";
				flag=true;
            }
        }
        //文件
        else
        {   
             ss<<L"\""<<FindFileData.cFileName<<L"\"";
			flag=true;
        }
        if(!FindNextFile(hFind,&FindFileData))
              break;
		else if(flag){
			ss<<L",";
		}
    }
	ss<<L"]";
    FindClose(hFind);
	return ss.str();
}
开发者ID:AlloyTeam,项目名称:webtop,代码行数:53,代码来源:system.cpp

示例3: RenameOldFile

bool CaffeineClientHandler::RenameOldFile(wstring filename)
{
    //  Determine if the file already exists.  We do this because of the fugly extension
    //  API we're using.
#ifdef __APPLE__
    return renameOldFile(filename);
#else
    bool retval = false;
    struct _stat buf = {0,};
    if(_wstat(filename.c_str(), &buf) == 0)
    {
        wstring fileExt = L"";

        unsigned index = filename.find_last_of('.');
        if (index != wstring::npos)
        {
            fileExt = filename.substr(index);
        }

        wstringstream newFileName;
        newFileName << filename.substr(0, index) << ".old" << fileExt;

        RenameOldFile(newFileName.str());
        _wrename(filename.c_str(), newFileName.str().c_str());
        retval = true;
    }

    return retval;
#endif

}
开发者ID:sfrancisx,项目名称:Caffeine,代码行数:31,代码来源:CaffeineClientHandler.cpp

示例4: CreateDirectory

DWORD
FileDownloader::Download(wstring what, wstring *toFile)
{
	DWORD dwStatus;
	BOOL folderCreated = FALSE;

	// Setup temp file paths etc 
	wstring tempFilePath = L"temp\\";
	//tempFilePath = *toFile;
	wchar_t* szTempPath = new wchar_t[1024];
	wchar_t* szTempFilePath = new wchar_t[1024];
	GetFullPathName(tempFilePath.c_str(), 1024, szTempFilePath, NULL);
	GetFullPathName(L"temp", 1024, szTempPath, NULL);
	tempFilePath = szTempFilePath;
	folderCreated = CreateDirectory(szTempPath, NULL);
	delete [] szTempPath;
	delete [] szTempFilePath;

	if(folderCreated == FALSE)
	{
		//printf("FileDownloader - ERROR - Could not create temp directory: %ls\n", tempPath.c_str());
		//return false;
	}
	tempFilePath += L"tempFile";
	
	wstring extension = what.substr(what.find_last_of(L"."));
	tempFilePath += extension;

	DeleteFile(tempFilePath.c_str());

	printf("Downloading to: %ls\n", tempFilePath.c_str());
	*toFile = tempFilePath;
	HRESULT result = URLDownloadToFile(NULL,
			what.c_str(),
			tempFilePath.c_str(),
			0,
			this
		);

	// Wait for connection signal
	dwStatus = WaitForSingleObject(hConnected, 30000);

	if(dwStatus == WAIT_TIMEOUT)
	{
		printf("FileDownloader - ERROR - Connection timeout\n");
		return CAPTURE_NE_CONNECT_ERROR_DL_TEMP_FILE;
	}
	printf("FileDownloader - Downloading file: %ls\n", what.c_str());

	// Wait for download to finish signal
	dwStatus = WaitForSingleObject(hDownloaded, 60000);
	if(dwStatus == WAIT_TIMEOUT)
	{
		printf("FileDownloader - ERROR - Download timeout\n");
		return CAPTURE_NE_CANT_DOWNLOAD_TEMP_FILE;
	}
	printf("FileDownloader - File Downloaded: %ls\n", what.c_str());
	return 0;
}
开发者ID:340211173,项目名称:capture-hpc,代码行数:59,代码来源:FileDownloader.cpp

示例5: GetFileWithoutExtension

wstring GetFileWithoutExtension(wstring str) {
  size_t pos = str.find_last_of(L".");

  if (pos != wstring::npos)
    str.resize(pos);

  return str;
}
开发者ID:vjcagay,项目名称:taiga,代码行数:8,代码来源:string.cpp

示例6: GetAppNameW

bool GetAppNameW(wstring& strPath)
{
    TCHAR modulePath[MAX_PATH];
    if (0 == GetModuleFileNameW(NULL, modulePath, MAX_PATH))
    {
        DOLOG("Get Current Module Name Failed!");
        return false;
    }
    strPath = modulePath;
    int pos = strPath.find_last_of(L'\\');
    if (wstring::npos == pos)
    {
        return false;
    }
    int count = strPath.size() - pos;
    strPath = strPath.substr(strPath.find_last_of(L'\\')+1, count);
    return true;
}
开发者ID:wp4398151,项目名称:TestProjectJar,代码行数:18,代码来源:UtilHelper.cpp

示例7: GetExtW

wstring GetExtW(wstring path){
	int index=path.find_last_of('.');
	if(index==-1){
		return L"";
	}
	else{
		wstring type=path.substr(index+1);
		return replace_allW(type,L"jpg",L"jpeg");
	}
}
开发者ID:AlloyTeam,项目名称:webtop,代码行数:10,代码来源:system.cpp

示例8: FileName

wstring FileName(const wstring& sBinaryPath)
{
	size_t i = sBinaryPath.find_last_of(L"/\\");
	if(i != sBinaryPath.npos)
	{
		return sBinaryPath.substr(i + 1);
	}
	else
	{
		return sBinaryPath;
	}
}
开发者ID:poorboy,项目名称:ProcessFileSystem,代码行数:12,代码来源:StringHelper.cpp

示例9: GetAppPathW

// 得到当前程序的路径
bool GetAppPathW(wstring& strPath)
{
    TCHAR modulePath[MAX_PATH];
    if (0 == GetModuleFileNameW(NULL, modulePath, MAX_PATH))
    {
        DOLOG("Get Current Module Name Failed!");
        return false;
    }
    strPath = modulePath;
    strPath  = strPath.substr(0, strPath.find_last_of(L'\\'));
    return true;
}
开发者ID:wp4398151,项目名称:TestProjectJar,代码行数:13,代码来源:UtilHelper.cpp

示例10:

// determine the file name for a given pathname
// (wstring only for now; feel free to make this a template if needed)
/*static*/ wstring File::FileNameOf(wstring path)
{
#ifdef WIN32
    static const wstring delim = L"\\:/";
#else
    static const wstring delim = L"/";
#endif
    auto pos = path.find_last_of(delim);
    if (pos != path.npos)
        return path.substr(pos + 1);
    else // no directory path
        return path;
}
开发者ID:BorisJineman,项目名称:CNTK,代码行数:15,代码来源:File.cpp

示例11: Assert

PixelShader::PixelShader(wstring path)
{
    HRESULT result;

    auto shaderBuffer = Tools::ReadFileToVector(path);
    result = GetD3D11Device()->CreatePixelShader(&shaderBuffer[0], shaderBuffer.size(), nullptr, &m_Shader);
    Assert(result == S_OK);

    auto extensionIndex = path.find_last_of('.');
    auto metadataBuffer = Tools::ReadFileToVector(path.substr(0, extensionIndex + 1) + L"shadermetadata");

    Reflect(shaderBuffer, metadataBuffer);
}
开发者ID:TautvydasZilys,项目名称:Direct3D-Sandbox,代码行数:13,代码来源:PixelShader.cpp

示例12: loadMesh

		Void Mesh::loadMesh(const wstring &sNewPath)
		{
			if(sNewPath.length() < 2u || sNewPath[1] != L':')
				return;

			BinaryReader sReader{sNewPath};

			if(!sReader.readerOpened())
				return;

			Char vSignature[8]
			{
				//Empty.
			};

			sReader.readCHAR(vSignature, 8u);
			
			if(vSignature[0] != 'P' ||
				vSignature[1] != 'H' ||
				vSignature[2] != 'S' ||
				vSignature[3] != '_' ||
				vSignature[4] != 'M' ||
				vSignature[5] != 'E' ||
				vSignature[6] != 'S' ||
				vSignature[7] != 'H')
				return;

			uInt nCount = sReader.readUINT();
			this->sMeshMaterialVector.reserve(nCount);

			const wstring sPath = sNewPath.substr(0u, sNewPath.find_last_of(L"\\/") + 1u);

			for(uInt nIndex = 0u ; nIndex < nCount ; ++nIndex)
			{
				this->sMeshMaterialVector.emplace_back(sReader, sPath);
				this->sMeshMaterialNameMap[this->sMeshMaterialVector.back().sMaterialName] = &this->sMeshMaterialVector.back();
			}

			nCount = sReader.readUINT();
			this->sMeshSubMeshVector.reserve(nCount);

			for(uInt nIndex = 0u ; nIndex < nCount ; ++nIndex)
			{
				this->sMeshSubMeshVector.emplace_back(sReader);
				auto iIndex = this->sMeshMaterialNameMap.find(this->sMeshSubMeshVector.back().sSubMeshMaterialName);
				
				if(iIndex != this->sMeshMaterialNameMap.end())
					this->sMeshSubMeshVector.back().pSubMeshMaterialPointer = iIndex->second;
			}
		}
开发者ID:AcrylicShrimp,项目名称:automatic-disco,代码行数:50,代码来源:PHsMesh.cpp

示例13: Trace

// Tracing routine
// Can throw HRESULT on invalid formats
void FunctionTracer::Trace(wstring file, int line, wstring functionName, wstring format, ...)
{
    if (m_traceEnabled)
    {
        wstring buffer;
        VPRINTF_VAR_PARAMS(buffer, format);
    
        size_t pos = file.find_last_of(L"\\");
        wstring fileName = (pos == file.npos)? file: file.substr(pos+1);

        // TODO - put here your own implementation of a tracing routine, if needed
        wprintf(L"[[%40s @ %10s:%4d]] %s\n", functionName.c_str(), fileName.c_str(), line, buffer.c_str());
    }
}
开发者ID:YY583456235,项目名称:vscsc,代码行数:16,代码来源:tracing.cpp

示例14:

VLDDexporter::CommandProcessor::CommandProcessor(const wstring &file){
	// open read //
	Reader.open(file, ios::in);

	// get path from the input file //
	wstring tmpstr = file.substr(0, 1+file.find_last_of('\\'));
	OutputFilePath = "";
	OutputFilePath.assign(tmpstr.begin(), tmpstr.end());


	// set default settings //
	OutputFile = DEFAULT_OUTPUTFILE;

}
开发者ID:hhyyrylainen,项目名称:VLD-Data-Exporter,代码行数:14,代码来源:CommandProcessor.cpp

示例15: HRESULT

// determine the directory for a given pathname
// (wstring only for now; feel free to make this a template if needed)
/*static*/ wstring File::DirectoryPathOf(wstring path)
{
#ifdef _WIN32
    // Win32 accepts forward slashes, but it seems that PathRemoveFileSpec() does not
    // TODO:
    // "PathCchCanonicalize does the / to \ conversion as a part of the canonicalization, it's
    // probably a good idea to do that anyway since I suspect that the '..' characters might
    // confuse the other PathCch functions" [Larry Osterman]
    // "Consider GetFullPathName both for canonicalization and last element finding." [Jay Krell]
    path = msra::strfun::ReplaceAll<wstring>(path, L"/", L"\\");

    HRESULT hr;
    if (IsWindows8OrGreater()) // PathCchRemoveFileSpec() only available on Windows 8+
    {
        typedef HRESULT(*PathCchRemoveFileSpecProc)(_Inout_updates_(_Inexpressible_(cchPath)) PWSTR, _In_ size_t);
        HINSTANCE hinstLib = LoadLibrary(TEXT("api-ms-win-core-path-l1-1-0.dll"));
        if (hinstLib == nullptr)
            RuntimeError("DirectoryPathOf: LoadLibrary() unexpectedly failed.");
        PathCchRemoveFileSpecProc PathCchRemoveFileSpec = reinterpret_cast<PathCchRemoveFileSpecProc>(GetProcAddress(hinstLib, "PathCchRemoveFileSpec"));
        if (!PathCchRemoveFileSpec)
            RuntimeError("DirectoryPathOf: GetProcAddress() unexpectedly failed.");

        // this is the actual function call we care about
        hr = PathCchRemoveFileSpec(&path[0], path.size());

        FreeLibrary(hinstLib);
    }
    else // on Windows 7-, use older PathRemoveFileSpec() instead
        hr = PathRemoveFileSpec(&path[0]) ? S_OK : S_FALSE;

    if (hr == S_OK) // done
        path.resize(wcslen(&path[0]));
    else if (hr == S_FALSE) // nothing to remove: use .
        path = L".";
    else
        RuntimeError("DirectoryPathOf: Path(Cch)RemoveFileSpec() unexpectedly failed with 0x%08x.", (unsigned int)hr);
#else
    auto pos = path.find_last_of(L"/");
    if (pos != path.npos)
        path.erase(pos);
    else // if no directory path at all, use current directory
        return L".";
#endif
    return path;
}
开发者ID:BorisJineman,项目名称:CNTK,代码行数:47,代码来源:File.cpp


注:本文中的wstring::find_last_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。