本文整理汇总了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 ;
};
示例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;
}
示例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() );
}
}
示例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;
}
示例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;
}
示例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;
}
示例7:
Path::Path(const Path& o)
{
SetPath(o.GetPath());
}