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


C++ Path::GetPath方法代码示例

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


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

示例1: ImportSample

int SamplePool::ImportSample(Path &path) {

	if (count_==MAX_PIG_SAMPLES) return -1 ;

	// construct target path

	std::string dpath="samples:" ;
	dpath+=path.GetName() ;
	Path dstPath(dpath.c_str()) ;

    // Opens files

	I_File *fin=FileSystem::GetInstance()->Open(path.GetPath().c_str(),"r") ;
	if (!fin) {
		Trace::Error("Failed to open input file %s",path.GetPath().c_str()) ;
		return -1;
	} ;
	fin->Seek(0,SEEK_END) ;
	long size=fin->Tell() ;
	fin->Seek(0,SEEK_SET) ;

	I_File *fout=FileSystem::GetInstance()->Open(dstPath.GetPath().c_str(),"w") ;
	if (!fout) {
		fin->Close() ;
		delete (fin) ;
		return -1 ;
	} ;

	// copy file to current project

	char buffer[IMPORT_CHUNK_SIZE] ;
	while (size>0) {
		int count=(size>IMPORT_CHUNK_SIZE)?IMPORT_CHUNK_SIZE:size ;
		fin->Read(buffer,1,count) ;
		fout->Write(buffer,1,count) ;
		size-=count ;
	} ;

	fin->Close() ;
	fout->Close() ;
	delete(fin) ;
	delete(fout) ;

	// now load the sample

	bool status=loadSample(dstPath.GetPath().c_str()) ;

	SetChanged() ;
	SamplePoolEvent ev ;
	ev.index_=count_-1 ;
	ev.type_=SPET_INSERT ;
	NotifyObservers(&ev) ;
	return status?(count_-1):-1 ;
};
开发者ID:EQ4,项目名称:LittleGPTracker,代码行数:54,代码来源:SamplePool.cpp

示例2:

// SetDirectory
status_t
UncachedDirIterator::SetDirectory(Directory* directory)
{
	// unset old
	if (fDirHandle) {
		closedir(fDirHandle);
		fDirHandle = NULL;
	}
	fDirectory = NULL;

	// set new
	if (directory) {
		// get the directory path
		Path path;
		status_t error = directory->GetPath(&path);
		if (error != B_OK)
			return error;

		// open the directory
		error = FDManager::OpenDir(path.GetPath(), fDirHandle);
		if (error != B_OK)
			return error;

		fDirectory = directory;
		fNodeRef = directory->GetNodeRef();
	}

	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:30,代码来源:Directory.cpp

示例3: Invoked

/** \brief Invoked
 * Handles when an icon within the view is invoked. If it is a directory
 * it should, the current directory should move into it. If it is a file
 * it should be opened if possible and otherwise it should be downloaded.
 *
 * \todo Should attempt to dowload and open the remote file if it's not a directory?
 * \todo What should be the default action when the file type is unknown?
 */
void RemoteIconView::Invoked( uint nIcon, IconData* pcData )
{
//	DEBUG( "RemoteIconView::Invoked on icon %i (%s)\n", nIcon, GetIconString( nIcon, 0 ).c_str() );
	
	RemoteIconData* pcRData = (RemoteIconData*)pcData;
	
	if( pcRData->m_cNode.IsDir() ) {
		Path cPath = m_zPath;
		cPath.Append( pcRData->m_cNode.m_zName );
		DEBUG( "RemoteView: Changing to %s\n", cPath.GetPath().c_str() );
		if( m_pcDirChangedMsg ) {
			Message cTmp = *m_pcDirChangedMsg;
			cTmp.AddString( "file/path", cPath.GetPath() );
			Invoke( &cTmp );
		}
		SetPath( cPath.GetPath() );
	}
}
开发者ID:PyroOS,项目名称:Pyro,代码行数:26,代码来源:remoteview.cpp

示例4: DrawPath

bool FieldView::DrawPath(const Path& path){
    //get dots container from givven path
    Path::Dots dots = path.GetPath();
    const size_t size = dots.size();
    
    if(dots.empty())        //if container with dots coordinats is empty, then exit
        return false;

    window = get_window();    //get pointer to parent window
    if(window){             //if pointer to window is not NULL...
        cr = window->create_cairo_context();
        if(cr){             //and if pointer to context is not NULL...
            allocation = get_allocation();
            
            cr->save();
            cr->rectangle(0, 0, allocation.get_width(), allocation.get_height());
            cr->clip();

            //choose color
            switch(path.GetColor()){
                case RED:
                    cr->set_source_rgb(1.0, 0.0, 0.0);
                    break;
                case BLUE:
                    cr->set_source_rgb(0.0, 0.0, 1.0);
                    break;
                default:
                    return false;
            }

            cr->set_line_width((ctrl->GetPrefs()->line_width) * 2);
            //move to start point
            cr->move_to((dots[0].GetX()+1) * CELL_SIZE * sx, (dots[0].GetY() + 1) * CELL_SIZE * sy);

            //here we will just move from one point to another while there is at least one of them
            for(size_t i = 1; i < size; i++)
                //we add 1 because field has some kind of "dead zone" on its sides
                cr->line_to((dots[i].GetX() + 1) * CELL_SIZE * sx, (dots[i].GetY() + 1) * CELL_SIZE * sy);
            cr->stroke();
            dots.clear();
            return true;
        }
    }
    return false;
}
开发者ID:Spo1ler,项目名称:gdots,代码行数:45,代码来源:classFieldView.cpp

示例5:

// Open
status_t
AttrDirIterator::Open(Node* node)
{
    if (!node)
        return B_BAD_VALUE;

    // get a path
    Path path;
    status_t error = node->GetPath(&path);
    if (error != B_OK)
        return error;

    // open the attribute directory
    error = FDManager::OpenAttrDir(path.GetPath(), fDir);
    if (error != B_OK)
        return errno;

    fNodeRef = node->GetNodeRef();

    return B_OK;
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:22,代码来源:NodeHandle.cpp

示例6: TreeCacheAdd

//=================================================================================
// I wonder if we should overwrite the cache entry in the case that
// a cache entry for the given path already exists.
bool Context::TreeCacheAdd( const Path& path, const Node* root )
{
	if( !treeCacheMap )
		treeCacheMap = new TreeCacheMap();

	std::string key;
	if( !path.GetPath( key, true ) )
		return false;

	TreeCacheMap::iterator iter = treeCacheMap->find( key );
	if( iter != treeCacheMap->end() )
		return false;

	Node::CopyParameters copyParameters;
	Node* clone = root->Clone( *this, copyParameters );
	if( !clone )
		return false;

	( *treeCacheMap )[ key ] = clone;
	return true;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:24,代码来源:Context.cpp

示例7:

Path::Path(const Path& o)
{
	SetPath(o.GetPath());
}
开发者ID:yingzhang536,项目名称:mrayy-Game-Engine,代码行数:4,代码来源:Path.cpp


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