本文整理汇总了C++中PathName::GetPath方法的典型用法代码示例。如果您正苦于以下问题:C++ PathName::GetPath方法的具体用法?C++ PathName::GetPath怎么用?C++ PathName::GetPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathName
的用法示例。
在下文中一共展示了PathName::GetPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTemplateFilename
bool CTemplateManager::GetTemplateFilename( UINT32 ordNumberOfTemplate, String_256* pStrNameOfFile )
{
// Fill the list with all templates (user local, begin second will over-write system ones)
CTemplateList setSortFilename;
GetTemplateList( &setSortFilename, m_TemplatesPath, false );
GetTemplateList( &setSortFilename, m_LocalTemplatesPath, true );
// If the template with ordinal doesn't exist, fail
if( ordNumberOfTemplate > UINT32(setSortFilename.size()) )
return false;
// Get enbry for template
CTemplateList::iterator iter = setSortFilename.begin();
for( UINT32 i = 1; i < ordNumberOfTemplate; ++i, ++iter )
{ /*Do nothing!*/ }
// Pre-pend the path to the template
PathName pathTemplates = iter->second ? m_LocalTemplatesPath : m_TemplatesPath;
pathTemplates.SetFileNameAndType( iter->first );
*pStrNameOfFile = pathTemplates.GetPath();
TRACEUSER( "jlh92", _T("Final(%d) = %s\n"), ordNumberOfTemplate, PCTSTR(*pStrNameOfFile) );
return true;
}
示例2: OpenThumbnailFile
BOOL SGThumbs::OpenThumbnailFile( CCDiskFile* pFile, const PathName& ThumbFileName ) const
{
ERROR3IF( pFile==NULL, "SGThumbs::OpenThumbnailFile passed a null ptr" );
TRACEUSER( "Martin", _T("Open thumb file: %s\n"), (const TCHAR *)ThumbFileName.GetPath() );
BOOL Found = FALSE;
if(!ThumbFileName.IsValid())
{
// either xarainfo\\<filename> or the actual clipart file
ERROR3("SGThumbs::OpenThumbnailFile received an invalid xarainfo\\<filename> file");
Error::ClearError();
return FALSE;
}
// Open file and check if it exists at the same time
if( !( Found = pFile->open( ThumbFileName, ios::in | ios::binary ) ) )
{
Found = FALSE;
Error::ClearError();
}
return Found;
}
示例3: DeletePathName
BOOL PlugInPathList::DeletePathName( const PathName& OldPath )
{
String_256 OldPathStr = OldPath.GetPath();
PlugInPath* pPath = (PlugInPath *)GetHead();
while (pPath)
{
PathName Path = pPath->GetPathName();
if (Path.GetPath() == OldPathStr)
{
RemoveItem(pPath);
// remove item returns NULL if problem
if (pPath == NULL)
return FALSE;
delete pPath;
return TRUE;
}
// Try the next pathname in the list
pPath = (PlugInPath *)GetNext(pPath);
}
// Failed to find the path in the list
return FALSE;
}
示例4: Do
void OpConvertFileFormats::Do(OpDescriptor*)
{
ERROR3 ("Please read the following comments BEFORE using this op!"); // comment this out to use the op
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// set up the search path, file util allows us just to pass the path/*.xar
String_256 SearchPath = TEXT ("d:\\clipart\\xara\\"); // YOU MUST CHANGE THIS PATH
String_256 FileSpecifier = SearchPath; // YOU MUST CHANGE THIS EXTENSION
FileSpecifier += TEXT("*.art");
String_256 FileSpecifier2 = TEXT("xar"); // YOU MUST CHANGE THIS EXTENSION
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ok = FileUtil::StartFindingFiles(&FileSpecifier);
active = TRUE;
String_256 Filename;
while (ok)
{
// fileutil will give us the next filename
ok = FileUtil::FindNextFile(&Filename);
String_256 FilePath = SearchPath;
FilePath += Filename;
PathName Path (FilePath);
if (ok)
{
CDocument* pDoc = theApp.OpenDocumentFile((TCHAR*)FilePath);
if (pDoc!=NULL)
{
// Make sure that the files name is sensible
theApp.MakeDocumentNative(pDoc, &Path);
Path.SetType (FileSpecifier2);
String_256 newPath = Path.GetPath ();
pDoc->DoSave ((TCHAR*) newPath, TRUE);
FileCloseAction ();
}
}
}
active = FALSE;
FileUtil::StopFindingFiles ();
}
示例5: HowCompatible
INT32 PluginOILFilter::HowCompatible(PathName& FileName)
{
INT32 HowCompatible = 0;
// Here we need to run the plugin synchronously with the following options
// -c -f <filename>
// Check stderr for errors
// Get HowCompatible from stdout
if (!m_CanImport.IsEmpty())
{
wxString sCommand(m_CanImport);
sCommand.Replace(_T("%IN%"), (LPCTSTR)FileName.GetPath());
TRACEUSER("Gerry", _T("Running '%s'"), sCommand.c_str());
wxArrayString saOutput;
wxArrayString saErrors;
INT32 code = wxExecute(sCommand, saOutput, saErrors, wxEXEC_NODISABLE);
TRACEUSER("Gerry", _T("wxExecute returned %d"), code);
if (code == 0)
{
// Extract the value from saOutput
if (saOutput.Count() > 0)
{
INT32 Val = wxAtoi(saOutput[0]);
TRACEUSER("Gerry", _T("Command '%s' returned string '%s'"), sCommand.c_str(), saOutput[0].c_str());
TRACEUSER("Gerry", _T("Value = %d"), Val);
if (Val >= 0 && Val <= 10)
{
HowCompatible = Val;
}
}
else
{
TRACEUSER("Gerry", _T("Command '%s' returned no output value"), sCommand.c_str());
}
}
else
{
TRACEUSER("Gerry", _T("Command '%s' exited with code %d"), sCommand.c_str(), code);
}
}
return(HowCompatible);
}
示例6: OnDownloadSuccess
void OpGenericDownload::OnDownloadSuccess()
{
// get a pointer to the OpParam so that I can retrieve some useful information
GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam;
String_256 GenericFile = (pGenericParam->file).GetFileName();
if (IsUserName("Olivier"))
TRACE1("OpGenericDownload::OnDownloadSuccess(), file = %s\n", (TCHAR*)GenericFile);
Filter* pFilter = pGenericParam->m_pFilter;
PathName Path = pGenericParam->file;
String_256 URL = pGenericParam->strURL;
SelOperation* Op = pGenericParam->m_Op;
// call the DoImport function from OpMenuImport class
((OpMenuImport*)Op)->DoImport(Path, pFilter, &URL);
// remove the temporary file
remove((TCHAR*) (String_256) Path.GetPath());
}
示例7: Init
INT32 LibraryFile::Init(SuperGallery *ParentGal, PathName *APath, SGLibType Type, BOOL Updated, BOOL DoScroll)
{
#ifndef EXCLUDE_GALS
if(ParentGal == NULL || APath == NULL || !Libraries.IsEmpty())
{
ERROR3("LibraryFile::Init - NULL parameters are illegal OR Init called > 1 times");
if(!Libraries.IsEmpty())
return(Libraries.GetCount());
else
return 0;
}
BOOL ok = TRUE;
// Tidy up Path a bit
String_256 OurPath(APath->GetPath());
LibraryFile::TidyUpSubPath(&OurPath);
// Now point Path to the new pathname
PathName ModifiedPath(OurPath);
PathName *Path = &ModifiedPath;
if(!ModifiedPath.IsValid())
{
ERROR3("LibraryFile::Init -> Modified library path is invalid");
return 0;
}
// Remember the pathname and type
MyPath = *Path;
MyType = Type;
ParentGallery = ParentGal;
if(ParentGallery->IsKindOf(CC_RUNTIME_CLASS(LibraryGallery)))
ParentLibraryGallery = (LibraryGallery *)ParentGal;
else
{
ERROR3("LibraryFile::Init passed a non-library gallery - yikes...");
return 0;
}
// Need to reset the Quiet status before a stream of Library::Init calls
ParentLibraryGallery->SetQuietStatus(FALSE);
BOOL Retry = TRUE;
while(Retry)
{
Retry = FALSE;
// Would be nice to have a way of adding a file to a path in PathName... Is there one ?
if(!SGLibOil::FileExists(Path))
{
// We're opening the font gallery, but can't find the font library path - don't warn
if(Type == SGLib_Font)
return 0;
// tell the user that the directory doesn't exist
String_256 WarnMsg;
String_256 DefaultIndex;
String_256 IndexDesc;
BOOL CanGenerate;
ok = LibraryFile::GetSubIndexDetails(ParentLibraryGallery, &DefaultIndex, &IndexDesc, &CanGenerate);
String_256 TmpPath(Path->GetLocation(FALSE));
LibraryFile::TidyUpSubPath(&TmpPath);
// Taken out by Graham 30/10/97: If the gallery had no directory specified,
//we used to throw a warning which said "do you want to specify another folder?"
//We don't do this any more, because the default is to open all galleries empty and
//then download stuff from the Xara web site
#if 0
WarnMsg.MakeMsg(_R(IDS_BROWSE_OR_SCAN), (TCHAR *)IndexDesc, (TCHAR *)TmpPath);
Error::SetError(0, WarnMsg, 0);
INT32 ButtonPressed = InformWarning(0, _R(IDS_BROWSE), _R(IDS_RETRY), _R(IDS_CANCEL)/*, _R(IDS_HELP)*/);
#else // WEBSTER
INT32 ButtonPressed = 3;
#endif // WEBSTER
TRACEUSER( "Richard", _T("ButtonPressed: %d\n"), ButtonPressed);
Error::ClearError();
switch(ButtonPressed)
{
case 1:
{
// Open the Browse dialog (or the Add.. dialog as it seems to be called now)
PathName ThePath(*Path);
// This returns FALSE if Cancel was hit, or an error occurred.
if(!SGLibOil::GetLibPath(ParentLibraryGallery, &ThePath, CanGenerate, Type))
{
ERROR3("GetLibPath returned FALSE in LF::Init");
return 0;
}
else
{
ModifiedPath = ThePath;
if(!ModifiedPath.IsValid())
{
ERROR3("LibraryFile::Init -> scanned library path is invalid");
return 0;
//.........这里部分代码省略.........
示例8: GetImportFile
BOOL PluginOILFilter::GetImportFile(CCLexFile* pFile, CCLexFile** ppNewFile)
{
ERROR2IF(pFile == NULL, FALSE,"PluginOILFilter::GetImportFile no file to import from");
ERROR2IF(ppNewFile == NULL, FALSE,"PluginOILFilter::GetImportFile no newfile pointer");
*ppNewFile = NULL;
// Here we should really run the plugin asynchronously with the following options
// -i -g -f <filename>
// Redirect stdout to a CCLexFile
// Check stderr during the Xar import and abort if an error is reported
m_TempXarFile.SetPathName(_T("/tmp/xpftemp.xar"));
CCDiskFile TempFile;
if (!TempFile.open(m_TempXarFile, ios::out | ios::trunc | ios::binary))
{
// report an error here
return FALSE;
}
PathName FileName = pFile->GetPathName();
wxString sCommand(m_DoImport);
sCommand.Replace(_T("%IN%"), (LPCTSTR)FileName.GetPath());
TRACEUSER("Gerry", _T("Running '%s'"), sCommand.c_str());
// Create a process with the TempFile as the stdout
PluginFilterProcess* pTheProc = new PluginFilterProcess((PluginNativeFilter*)Parent, NULL, &TempFile);
INT32 code = pTheProc->Execute(sCommand);
TempFile.close();
if (code != 0)
{
TRACEUSER("Gerry", _T("Execution of '%s' failed."), sCommand.c_str());
// Extract error from a derived CamProcess class and report it
pTheProc->ReportError();
delete pTheProc;
return(FALSE);
}
pTheProc->ReportWarning();
delete pTheProc;
pTheProc = NULL;
CCDiskFile* pTempFile = new CCDiskFile();
if (pTempFile)
{
if (pTempFile->open(m_TempXarFile, ios::in | ios::binary))
{
*ppNewFile = pTempFile;
return(TRUE);
}
delete pTempFile;
}
return(FALSE);
}
示例9: Do
void OpMenuSave::Do(OpDescriptor* pOpDesc)
{
//First get the selected document
Document* pdocToSave=Document::GetSelected();
CCamDoc* pccamdocToSave = pdocToSave->GetOilDoc();
if (pdocToSave==NULL || pccamdocToSave==NULL)
{
ERROR2RAW("No default document!");
return;
}
//And we'll need a pointer to the application
Application* pCamelot = GetApplication();
CTemplateManager& TemplateManager( pCamelot->GetTemplateManager() );
//And put the default templates path in the dialog
PathName pathToPutInDialog = TemplateManager.GetTemplatesPath();
FileUtil::RecursiveCreateDirectory( pathToPutInDialog.GetPath() );
//Now create the dialog
SaveTemplateDialog dialogToDisplay(pathToPutInDialog);
//And show it
if (dialogToDisplay.ShowModal() == wxID_OK)
{
//Then get the path they specified, using this amazingly bad, confusing and
//undocumented file dialog code
//The "CString" reference should ideally go in Winoil
PathName pathToSaveTo;
dialogToDisplay.GetChosenFileName(&pathToSaveTo);
wxString cstrPathToSaveTo=pathToSaveTo.GetPath(FALSE);
dialogToDisplay.AppendExtension(&cstrPathToSaveTo);
String_256 strPathToSaveTo=cstrPathToSaveTo;
pathToSaveTo=strPathToSaveTo;
// Create the save file.
CCDiskFile file(pathToSaveTo, ios::out | ios::binary | ios::trunc);
// First find the filter.
Filter *pFilter = FindFilter ( FILTERID_NATIVE );
// Tell it to save attributes.
pFilter->SetSaveAttributes ( TRUE );
// Then save the image to the file.
Save ( pFilter, &file );
//Now, if we should make that path the default path
if (SaveTemplateDialog::m_fUseAsDefault)
{
if (pdocToSave->IsAnimated())
{
CTemplateManager::SetDefaultAnimationTemplate( strPathToSaveTo );
}
else
{
CTemplateManager::SetDefaultDrawingTemplate( strPathToSaveTo );
}
}
if (SaveTemplateDialog::m_fDefaultTemplatesFolder)
{
String_256 strDefaultPath = pathToSaveTo.GetLocation( TRUE );
CTemplateManager::SetTemplatesPath( strDefaultPath );
}
}
// Finished the operation
End();
}
示例10: LoadFile
BOOL OpMenuLoad::LoadFile(CCLexFile* pFileToLoad, UINT32 nPrefFilter)
{
// Make sure we have a valid file to load.
/* TRACEUSER( "JustinF", _T("In OpMenuLoad::LoadFile(%p, %u)\n"),
(LPVOID) pFileToLoad, nPrefFilter);
*/ ERROR3IF(!pFileToLoad, "Null CCLexFile* in OpMenuLoad::LoadFile");
// Find out the position of the filter selected by the user in the open dialog
INT32 SelectedPos = 0;
#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
SelectedPos = BaseFileDialog::SelectedFilter;
#endif
// Go get the first filter in the list
Filter* pFilter = Filter::GetFirst();
// Do we know which filter was used? (we know nothing about things in the recent file
// list). If we don't, then use the preferred one, by default the generic filter.
if (nPrefFilter != FILTERID_USERCHOICE || SelectedPos == 0)
{
// We know nothing. We will have to go and have a look at all the possibles
// We will find the Filter Family and ask it to try and load the file.
UINT32 nID = (nPrefFilter != FILTERID_USERCHOICE) ? nPrefFilter : FILTERID_GENERIC;
while (pFilter != NULL && pFilter->FilterID != nID)
{
// Try the next filter
pFilter = Filter::GetNext(pFilter);
}
}
else
{
// We know which type of filter the user had selected in the file dialog
// Find the filter that the user chose.
while (pFilter != NULL)
{
// This is the filter?
if (pFilter->GetFlags().CanImport &&
pFilter->pOILFilter->Position == SelectedPos)
break;
// Try the next filter
pFilter = Filter::GetNext(pFilter);
}
}
// Check that the Filter existed
if (pFilter == NULL)
{
// It did not...
InformError(_R(IDT_CANT_FIND_FILTER));
return FALSE;
}
// Get pointer to current doc 'cos we'll need it several times...
Document* pCurDoc = Document::GetCurrent();
// If this is not a filter family, check for compatibility before asking
// filter to load the file.
// This means the user has chosen an explicit filter to handle the import
PathName Path = pFileToLoad->GetPathName();
String_256 FilePath = Path.GetPath();
// FilePath will be null if a pathname is not valid
if (!pFilter->IS_KIND_OF(FilterFamily) && !FilePath.IsEmpty())
{
UINT32 Size = 1024;
size_t FileSize;
ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize);
// If there has been a problem in the load initial segment then fail now.
if (FilterBuf == NULL)
{
// Tell the user about the problem and get out now while the goings good
InformError();
return FALSE;
}
// Inform any filters that we are about to do a HowCompatible call.
// This would allow a set of filters which have common functionality hidden in a
// filter that cannot import and cannot export handle this call and hence set
// itself up. This would allow it to maybe cache a result which should only be
// checked by the first filter in the group.
pFilter->PreHowCompatible();
// Change this to be less than 8 as the filters like the Accusoft forms return
// 8 and 9 to make sure that they are last in the chain.
if (pFilter->HowCompatible(Path, FilterBuf, Size, UINT32(FileSize)) < 8)
{
// Not 100% happy with this file - ask for confirmation.
ErrorInfo Question;
Question.ErrorMsg = _R(IDW_OPENQUERY_NOTSURE);
Question.Button[0] = _R(IDB_OPENQUERY_OPEN);
Question.Button[1] = _R(IDB_OPENQUERY_DONTOPEN);
if ((ResourceID)AskQuestion(&Question) != _R(IDB_OPENQUERY_OPEN))
{
// User asked for this to be cancelled.
TRACEUSER( "Tim", _T("Filter compatibility was less than 10\n"));
// Close the file, report the abort and finish.
//.........这里部分代码省略.........
示例11: ImportURL
BOOL OpBevel::ImportURL(WebAddress urlToGet)
{
//First, set up some variables. We must do this now because I'm
//going to use a goto in a moment
GenericDownloadParam* Param;
OpDescriptor* pOpDesc;
PathName pthTemp;
//We want to import urlToGet using the best available filter
//To get the best available filter, we simply download to the "All" filter
//So get a pointer to the All filter
Filter* pAllFilter=GetAllFilter();
//Check we found it
if (pAllFilter==NULL)
goto ReturnError;
//Now, get ready to download the file. This is rather complex.
//First create a new set of download parameters
//This object will be deleted when the download finishes
Param = new GenericDownloadParam;
//Now find the generic download OpDescriptor
pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_OPGENERICDOWNLOAD);
//And check we found it
if (pOpDesc==NULL)
goto ReturnError;
//Now, create a temporary file to download to
pthTemp=FileUtil::GetTemporaryPathName();
//And now fill in our parameters
Param->type = TYPE_HTML;
Param->priority = AsynchDownload::PRIORITY_NORMAL;
Param->strDescription = String_256(_R(IDS_HTMLIMPORT_FILEDOWNLOAD));
Param->file = pthTemp.GetPath();
Param->strURL = urlToGet.GetWebAddress();
Param->Output = NULL;
Param->m_pFilter = pAllFilter;
Param->m_Op = this;
Param->pDoc = Document::GetCurrent();
//And, finally, start the download going, if we've got a URL to download
if (!Param->strURL.IsEmpty())
pOpDesc->Invoke((OpParam*) Param);
//And return TRUE
return TRUE;
ReturnError:
if (Param)
delete Param;
return FALSE;
}