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


C++ path::c_str方法代码示例

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


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

示例1: CreateOrUpdateShortcutLink

bool CreateOrUpdateShortcutLink(fs::path const& shortcut_path, fs::path const& target_path)
{
    bool shortcut_existed = fs::exists(shortcut_path);

    {
        base::com::unique_ptr<IShellLinkW> pShellLink;
        HRESULT hr = pShellLink.CreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
        if (FAILED(hr))
            return false;

        pShellLink->SetPath(target_path.c_str());

        base::com::unique_ptr<IPersistFile> pPf;
        hr = pPf.QueryFrom(pShellLink.get());
        if (FAILED(hr))
            return false;

        hr = pPf->Save(shortcut_path.c_str(), TRUE);
        if (FAILED(hr))
            return false;

    }

    if (shortcut_existed)
    {
        ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
    }
    else
    {
        ::SHChangeNotify(SHCNE_CREATE, SHCNF_PATH, shortcut_path.c_str(), NULL);
    }

    return true;
}
开发者ID:9tong,项目名称:YDWE,代码行数:34,代码来源:Shortcuts.cpp

示例2: parseShader

std::string Shader::parseShader( const fs::path &path, bool optional, int level )
{
	std::stringstream output;

	if( level > 32 ) {
		throw std::runtime_error( "Reached the maximum inclusion depth." );
		return std::string();
	}

	static const std::regex includeRegexp( "^[ ]*#[ ]*include[ ]+[\"<](.*)[\">].*" );

	std::ifstream input( path.c_str() );
	if( !input.is_open() ) {
		if( optional )
			return std::string();

		if( level == 0 ) {
			char msg[512];
			snprintf( msg, 512, "Failed to open shader file '%s'.", path.c_str() );
			throw std::runtime_error( msg );
		}
		else {
			char msg[512];
			snprintf( msg, 512, "Failed to open shader include file '%s'.", path.c_str() );
			throw std::runtime_error( msg );
		}

		return std::string();
	}

	// go through each line and process includes
	std::string line;
	std::smatch matches;

	while( std::getline( input, line ) ) {
		if( std::regex_search( line, matches, includeRegexp ) )
			output << parseShader( path.parent_path() / matches[1].str(), false, level + 1 );
		else
			output << line;

		output << std::endl;
	}

	input.close();

	// make sure #version is the first line of the shader
	if( level == 0 )
		return parseVersion( output.str() );
	else
		return output.str();
}
开发者ID:Gazoo101,项目名称:Cinder-Samples,代码行数:51,代码来源:Shader.cpp

示例3: input

/// Applies a set of templates to an input file and writes an output file.
///
/// \param templates The templates to use.
/// \param input_file The path to the input to process.
/// \param output_file The path to the file into which to write the output.
///
/// \throw text::error If the input or output files cannot be opened.
/// \throw text::syntax_error If there is any problem processing the input.
void
text::instantiate(const templates_def& templates,
                  const fs::path& input_file, const fs::path& output_file)
{
    std::ifstream input(input_file.c_str());
    if (!input)
        throw text::error(F("Failed to open %s for read") % input_file);

    std::ofstream output(output_file.c_str());
    if (!output)
        throw text::error(F("Failed to open %s for write") % output_file);

    instantiate(templates, input, output);
}
开发者ID:racktopsystems,项目名称:kyua,代码行数:22,代码来源:templates.cpp

示例4: short

/*
This function is still a proof of concept, it's probably rife with bugs, below
is a short (and incomplete) todo
 * "Basic" checks (Read/Write/File/Dir) checks for FAT32 filesystems which
   requires detecting the filesystem being used.
*/
void Check(fs::path const& file, acs::Type type) {
	DWORD file_attr = GetFileAttributes(file.c_str());
	if ((file_attr & INVALID_FILE_ATTRIBUTES) == INVALID_FILE_ATTRIBUTES) {
		switch (GetLastError()) {
			case ERROR_FILE_NOT_FOUND:
			case ERROR_PATH_NOT_FOUND:
				throw fs::FileNotFound(file);
			case ERROR_ACCESS_DENIED:
				throw fs::ReadDenied(file);
			default:
				throw fs::FileSystemUnknownError(str(boost::format("Unexpected error when getting attributes for \"%s\": %s") % file % util::ErrorString(GetLastError())));
		}
	}

	switch (type) {
		case FileRead:
		case FileWrite:
			if ((file_attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
				throw fs::NotAFile(file);
			break;
		case DirRead:
		case DirWrite:
			if ((file_attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
				throw fs::NotADirectory(file);
			break;
	}

	SECURITY_INFORMATION info = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION;
	DWORD len = 0;
	GetFileSecurity(file.c_str(), info, nullptr, 0, &len);
	if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
		LOG_W("acs/check") << "GetFileSecurity: fatal: " << util::ErrorString(GetLastError());

	std::vector<uint8_t> sd_buff(len);
	SECURITY_DESCRIPTOR *sd = (SECURITY_DESCRIPTOR *)&sd_buff[0];

	if (!GetFileSecurity(file.c_str(), info, sd, len, &len))
		LOG_W("acs/check") << "GetFileSecurity failed: " << util::ErrorString(GetLastError());

	ImpersonateSelf(SecurityImpersonation);
	HANDLE client_token;
	if (!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &client_token))
		LOG_W("acs/check") << "OpenThreadToken failed: " << util::ErrorString(GetLastError());

	if (!check_permission(true, sd, client_token))
		throw fs::ReadDenied(file);
	if ((type == DirWrite || type == FileWrite) && !check_permission(false, sd, client_token))
		throw fs::WriteDenied(file);
}
开发者ID:KagamiChan,项目名称:Aegisub,代码行数:55,代码来源:access.cpp

示例5: Save

	void BossLog::Save(const fs::path file, const bool overwrite) {
		if (fs::exists(file))
			recognisedHasChanged = HasRecognisedListChanged(file);

		ofstream outFile;
		if (overwrite)
			outFile.open(file.c_str());
		else
			outFile.open(file.c_str(), ios_base::out|ios_base::app);
		if (outFile.fail())
			throw boss_error(BOSS_ERROR_FILE_WRITE_FAIL, file.string());

		outFile << PrintLog();
		outFile.close();
	}
开发者ID:Baron59,项目名称:boss,代码行数:15,代码来源:Output.cpp

示例6: trash

void trm::Database::createEntry(fs::path path, fs::path trashPath, std::size_t size)
{
    sqlite3_stmt *stmt;
    std::string objectName = trashPath.filename().string();
    const char *cPath = path.remove_filename().c_str();

    char sql[] =  "INSERT INTO trash (OBJECTNAME, FILESIZE, TRASHPATH, OLDPATH, DELETEDAT) "
                        "VALUES (?, ?, ?, ?, datetime('NOW', 'localtime'));";
    dbStatus = sqlite3_prepare(db, sql, -1, &stmt, 0);
    if (dbStatus != SQLITE_OK)
    {
        std::cout << "Database Error: " << errMsg << std::endl;
        exit(0);
    }

    if (sqlite3_bind_text(stmt, 1, objectName.c_str(), -1, SQLITE_STATIC) != SQLITE_OK)
        std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl;
    if (sqlite3_bind_int(stmt, 2, static_cast<int>(size)) != SQLITE_OK)
        std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl;
    if (sqlite3_bind_text(stmt, 3, trashPath.c_str(), -1, SQLITE_STATIC) != SQLITE_OK)
        std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl;
    if (sqlite3_bind_text(stmt, 4, cPath, -1, SQLITE_STATIC))
        std::cout << "Database Bind Error: " << sqlite3_errmsg(db) << std::endl;

    if (sqlite3_step(stmt) != SQLITE_DONE)
        std::cout << "Database Execute Error: " << sqlite3_errmsg(db) << std::endl;
}
开发者ID:bennisen,项目名称:TrashManager,代码行数:27,代码来源:database.cpp

示例7: ResolveShortcut

bool ResolveShortcut(fs::path const& shortcut_path, fs::path* target_path)
{
    HRESULT hr;
    base::com::unique_ptr<IShellLinkW> pShellLink;

    hr = pShellLink.CreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
    if (FAILED(hr))
        return false;

    base::com::unique_ptr<IPersistFile> pPf;

    hr = pPf.QueryFrom(pShellLink.get());
    if (FAILED(hr))
        return false;

    hr = pPf->Load(shortcut_path.c_str(), STGM_READ);
    if (FAILED(hr))
        return false;

    wchar_t temp[MAX_PATH];
    if (target_path)
    {
        hr = pShellLink->Resolve(0, SLR_NO_UI | SLR_NOSEARCH);
        if (FAILED(hr))
            return false;

        hr = pShellLink->GetPath(temp, MAX_PATH, NULL, SLGP_UNCPRIORITY);
        if (FAILED(hr))
            return false;

        *target_path = fs::path(temp);
    }

    return true;
}
开发者ID:9tong,项目名称:YDWE,代码行数:35,代码来源:Shortcuts.cpp

示例8: loadMovie

bool ciWMFVideoPlayer::loadMovie( const fs::path &filePath, const string &audioDevice )
{
    if (!_player)
    {
        //ofLogError("ciWMFVideoPlayer") << "Player not created. Can't open the movie.";
        return false;
    }

    DWORD fileAttr = GetFileAttributesW( filePath.c_str() );
    if (fileAttr == INVALID_FILE_ATTRIBUTES)
    {
        CI_LOG_E( "The video file could not be found: '" << filePath );
        //ofLog(OF_LOG_ERROR,"ciWMFVideoPlayer:" + s.str());
        return false;
    }

    //CI_LOG_I( "Videoplayer[" << _id << "] loading " << name );
    HRESULT hr = S_OK;
    string s = filePath.string();
    std::wstring w(s.length(), L' ');
    std::copy(s.begin(), s.end(), w.begin());

    std::wstring a(audioDevice.length(), L' ');
    std::copy(audioDevice.begin(), audioDevice.end(), a.begin());

    hr = _player->OpenURL( w.c_str(), a.c_str() );
    if (!_sharedTextureCreated)
    {
        _width = _player->getWidth();
        _height = _player->getHeight();

        gl::Texture::Format format;
        format.setInternalFormat(GL_RGBA);
        format.setTargetRect();
        _tex = gl::Texture::create(_width,_height, format);
        //_tex.allocate(_width,_height,GL_RGBA,true);
        _player->m_pEVRPresenter->createSharedTexture(_width, _height, _tex->getId());
        _sharedTextureCreated = true;
    }
    else
    {
        if ((_width != _player->getWidth()) || (_height != _player->getHeight()))
        {
            _player->m_pEVRPresenter->releaseSharedTexture();

            _width = _player->getWidth();
            _height = _player->getHeight();

            gl::Texture::Format format;
            format.setInternalFormat(GL_RGBA);
            format.setTargetRect();
            _tex = gl::Texture::create(_width,_height, format);
            //_tex.allocate(_width,_height,GL_RGBA,true);
            _player->m_pEVRPresenter->createSharedTexture(_width, _height, _tex->getId());
        }
    }

    _waitForLoadedToPlay = false;
    return true;
}
开发者ID:Gazoo101,项目名称:Cinder-WMFVideo,代码行数:60,代码来源:ciWMFVideoPlayer.cpp

示例9: transform

void transform(fs::path xslt, std::string inputfile, std::string outputfile)
{
    auto stylesheet = xsltParseStylesheetFile(BAD_CAST xslt.c_str());
    auto doc = xmlParseFile(inputfile.c_str());

    const char *params = NULL;
    auto result = xsltApplyStylesheet(stylesheet, doc, &params);
    xsltSaveResultToFilename(outputfile.c_str(), result, stylesheet, 0);

    xmlFreeDoc(doc);
    xmlFreeDoc(result);
    xsltFreeStylesheet(stylesheet);
}
开发者ID:rikardn,项目名称:libpharmmlcpp,代码行数:13,代码来源:pharmmltool.cpp

示例10: get_name

	std::string get_name(const fs::path& fil_path)
	{
		try
		{
			base::file::memory_mapped_file mmap(fil_path.c_str());
			const char* memory_ptr = static_cast<const char*>(mmap.memory());
			if (memory_ptr)
			{
				return get_name(memory_ptr);
			}
		}
		catch (std::exception const&) {}

		return std::move(std::string());
	}
开发者ID:chanchancl,项目名称:YDWE,代码行数:15,代码来源:file.cpp

示例11: runtime_error

    TorchModel (fs::path const &lua_config, fs::path const& model_path, int batch, int H, int W, int C)
        : state(luaL_newstate())
    // we are taking in input tensor shape here
    // will have to change code to get the shape from the lua_config
    {
        BOOST_VERIFY(batch >= 1);
        if (!state) throw std::runtime_error("failed to initialize Lua");
        luaL_openlibs(state);
        int result = luaL_loadfile(state, lua_config.c_str());
        if (result != 0) throw std::runtime_error("failed to load openface server");
        result = lua_pcall(state, 0, LUA_MULTRET, 0);
        if (result != 0) throw std::runtime_error("failed to run openface server");
        // call lua's setup with model path
        lua_getglobal(state, "setup");
        lua_pushstring(state, model_path.c_str());
        if (lua_pcall(state, 1, 0, 0) != 0) {
            throw std::runtime_error("fail to extract");
        }

        shape[0] = batch;
        shape[1] = C;
        shape[2] = H;
        shape[3] = W;
    }
开发者ID:aaalgo,项目名称:xnn,代码行数:24,代码来源:torch.cpp

示例12: reloadAsset

void AssetReloader::reloadAsset( fs::path assetPath )
{
    
    //    console() << "reload :: " << mKeyList[ assetPath.c_str() ] << endl;
    
    string key = "";
    key = mKeyList[ assetPath.c_str() ];
    
    if( key != "" ){
        console() << "AssetReloader :: reloading asset :: " << assetPath.filename() << endl;
        load( assetPath.filename(), key );
        // fire signal
        sAssetReloaded();
    }else{
        console() << "AssetReloader :: can't reload " << assetPath.filename() << endl;
    }
}
开发者ID:cwhitney,项目名称:AssetReloader,代码行数:17,代码来源:AssetReloader.cpp

示例13: getSHA

std::string Database::getSHA(fs::path filepath) {
	LOG4CPLUS_DEBUG(logger, "Getting SHA for path " << filepath);

	boost::mutex::scoped_lock lock(dbMutex);
	sqlite3_bind_text(getSHAqueryStmt, 1, filepath.c_str(), filepath.string().size(), SQLITE_STATIC );

	int response = sqlite3_step(getSHAqueryStmt);
	std::string sha;

	if (SQLITE_ROW == response) {
		std::string resultPath;
		sha = (reinterpret_cast<const char*>(sqlite3_column_text(getSHAqueryStmt, 0)));
		LOG4CPLUS_DEBUG(logger, "Found SHA " << sha << " for file " << filepath);
	}

	sqlite3_reset(getSHAqueryStmt);

	return sha;
}
开发者ID:yanguanglan,项目名称:imageHasher,代码行数:19,代码来源:Database.cpp

示例14: launch

ProcessWithThread Process::launch(const fs::path& app, const wstring& args,
	optional<const vector<string>&> env,
	optional<const wstring&> cwd,
	bool inheritHandles, DWORD creationFlags,
	SECURITY_ATTRIBUTES* processAttributes, SECURITY_ATTRIBUTES* threadAttributes,
	STARTUPINFOW startupInfo)
{
	startupInfo.cb = sizeof(STARTUPINFOW); // needed
	PROCESS_INFORMATION pi = {};
	wstring commandLine = app.wstring() + L" " + args;

	if (!CreateProcessW(app.c_str(), &commandLine[0], processAttributes, threadAttributes, inheritHandles,
			creationFlags, nullptr, nullptr, &startupInfo, &pi))
	{
		DWORD errcode = GetLastError();
		BOOST_THROW_EXCEPTION(ex_injection() << e_api_function("CreateProcess") << e_last_error(errcode) << e_file(app));
	}
	else
		return ProcessWithThread(Process(pi.dwProcessId, pi.hProcess), Thread(pi.dwThreadId, pi.hThread));
}
开发者ID:guneysu-arsiv,项目名称:injectory,代码行数:20,代码来源:process.cpp

示例15: hasSHA

bool Database::hasSHA(fs::path filepath) {
	boost::mutex::scoped_lock lock(dbMutex);

	LOG4CPLUS_DEBUG(logger, "Looking if " << filepath << " has SHA");

	sqlite3_bind_text(checkSHAStmt, 1, filepath.c_str(), filepath.string().size(), SQLITE_STATIC);


	sqlite3_step(checkSHAStmt);
		int response = sqlite3_column_int(checkSHAStmt, 0);
		sqlite3_reset(checkSHAStmt);

		if (response == 1) {
			return true;
		} else {
			return false;
		}

	return false;
}
开发者ID:yanguanglan,项目名称:imageHasher,代码行数:20,代码来源:Database.cpp


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