本文整理汇总了C++中CFile::GetFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::GetFilePath方法的具体用法?C++ CFile::GetFilePath怎么用?C++ CFile::GetFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::GetFilePath方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void CProfile::Init()
{
// Keep track whether the profile was changed.
m_bNeedsSave = false;
CFile file;
// Load the profile array from the storage file.
if(!file.Open(m_strDataFileName, CFile::modeRead))
{
// File didn't open properly so just set the filename.
// we will create a new file later at destruction time.
m_strDataFullPath = file.GetFilePath();
}
else
{
// Open the existing file and read in the data.
m_strDataFullPath = file.GetFilePath();
for(int i=0; i<TABLE_SIZE; ++i)
{
_ReadElement(file, m_ProfileTable[i].strSection, m_ProfileTable[i].strEntry, m_ProfileTable[i].strValue);
}
file.Close();
}
}
示例2: Serialize
void CResourceListDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// There is nothing to save.
int x = 0;
}
else
{
CFile *pFile = ar.GetFile();
// Set the current directory, so we know where to look for the resource files.
// If not, clicking on an item in the recent documents list won't work
CString path = pFile->GetFilePath();
path.MakeLower();
int iFileOffset = path.Find(TEXT("\\resource.map"));
if (iFileOffset > 0)
{
path.SetAt(iFileOffset, 0); // Null terminate it
// Set this folder as our new game folder
CResourceMap &map = theApp.GetResourceMap();
map.SetGameFolder((PCSTR)path);
theApp.LogInfo(TEXT("Open game: %s"), (PCTSTR)path);
UpdateAllViews(NULL, VIEWUPDATEHINT_RESOURCEMAPCHANGED, pFile);
}
else
{
AfxMessageBox(TEXT("SCI game resources must be called resource.map"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
示例3: CreatNewFile
// //创建新的数据保存文件
bool CDlgSavedata::CreatNewFile(CString fileName)
{
//theApp.str_fileName.Format(_T("%s%s"),_T("SaveData\\"),fileName);
//theApp.str_fileName = fileName;
CString newfileName;
CString directrory;
CFile file;
CFileException exception;//保存错误信息
directrory = _T("SaveData");
if (! (GetFileAttributes(directrory) == FILE_ATTRIBUTE_DIRECTORY)) //先判断是否存在文件夹,如果不是,则创建文件夹
{
if(! CreateDirectory(directrory,NULL))
{
MessageBox(_T("创建SaveData文件夹失败!"),NULL,MB_OK|MB_ICONWARNING);
return false;
}
}
newfileName.Format(_T("%s\\%s"),directrory,fileName);
if (! file.Open(newfileName,CFile::modeCreate | CFile::modeReadWrite, &exception)) //创建文件
{
MessageBox(_T("创建保存文件失败!"),NULL,MB_OK|MB_ICONWARNING);
return false;
}
theApp.str_fileName = file.GetFilePath();
return true;
}
示例4: CloseLogFile
void CloseLogFile(CFile& file)
{
if(file.m_hFile != CFile::hFileNull)
{
CString szFileName = file.GetFilePath();
ULONGLONG uSize = file.GetLength();
file.Close();
if(uSize == 0)
CFile::Remove(szFileName);
}
}
示例5: OnTimer
void CBuildMap::OnTimer(UINT nIDEvent)
{
if(m_PongsTimerID == nIDEvent)
{
//m_stcNodes.SetWindowText( CommaIze( DWrdtoStr( m_pComm->MapTable.size())));
if(m_Building)
{
bool Finished = false;
CFile NetMap;
if( NetMap.Open((m_pDoc->m_RunPath + "Graphing\\graph.gif"), CFile::modeRead, NULL))
{
Finished = true;
CString Path = NetMap.GetFilePath();
NetMap.Close();
m_pFrame->OpenBrowser(Path);
}
else
{
CString Dots;
m_btnBuild.GetWindowText(Dots);
if(Dots.Find("...") != -1)
m_btnBuild.SetWindowText("Building");
else
m_btnBuild.SetWindowText(Dots + ".");
m_TimeBuilding++;
if(m_TimeBuilding == 60)
AfxMessageBox("This map has been building for a minute,\r\n your map is probably too big to be created.\r\n\r\nEither continue waiting or use CTRL-ALT-DEL\r\nand Select End Task, Neato.\r\n\r\nLess intensive settings enable the map to be built faster.");
// Expand this so gnucleus ends Neato for the user
// FindWindow("tty", "Neato"); to get the window
}
if(Finished)
{
m_Building = false;
m_btnRefresh.EnableWindow(true);
m_btnBuild.EnableWindow(true);
m_btnBuild.SetWindowText("Build Map");
}
}
}
CDialog::OnTimer(nIDEvent);
}
示例6: Serialize
void CSgviewerDoc::Serialize(CArchive& ar)
{
CSgviewerApp::getApp().setPause( true );
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
try
{
CFile* file = ar.GetFile();
if ( file )
{
Texture::flushTextures();
CString pathstr = file->GetFilePath();
String path = (const char*)pathstr;
String dir = File(path).getParent();
P(DirectoryInputStreamArchive) arch = new DirectoryInputStreamArchive;
arch->addPath( dir );
P(ModelFileCache) modelcache = new ModelFileCache( arch );
P(SceneFile) sf = new SceneFile( path, modelcache, arch );
modelcache->clear();
scene = sf->scene();
name = path;
cube1 = cube2 = 0;
prepareDoc();
}
}
catch ( Throwable& e )
{
char buf[1000];
e.getMessage().format().getBytes( buf, sizeof(buf), "ASCII-7" );
if ( CSgviewerApp::getApp().m_pMainWnd )
CSgviewerApp::getApp().m_pMainWnd->MessageBox( buf, "Error - sgviewer", MB_OK|MB_ICONERROR|MB_SYSTEMMODAL );
else
MessageBox( 0, buf, "Error - sgviewer", MB_OK|MB_ICONERROR|MB_SYSTEMMODAL );
}
}
CSgviewerApp::getApp().setPause( false );
}
示例7: Serialize
void CPLYEditorDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
CFile* cfile = ar.GetFile();
CString filename = cfile->GetFilePath(); // return full path and filename
//::MessageBox(0, filename, L"Hello", MB_OK);
char fn[200];
strcpy(fn, CStringA(filename).GetString());
Mesh* m = readFile(fn);
theApp.AddToRecentFileList(filename.GetString());
this->LMesh.push_back(m);
this->UpdateAllViews(NULL);
}
}
示例8: Serialize
void CResourceMapDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// There is nothing to save.
int x = 0;
}
else
{
CFile *pFile = ar.GetFile();
// Set the current directory, so we know where to look for the resource files.
// If not, clicking on an item in the recent documents list won't work
CString path = pFile->GetFilePath();
path.MakeLower();
int iFileOffset = path.Find(TEXT("\\resource.map"));
if (iFileOffset > 0)
{
path.SetAt(iFileOffset, 0); // Null terminate it
// Set this folder as our new game folder
CResourceMap &map = theApp.GetResourceMap();
map.SetGameFolder(path);
// Close it. We only wanted the path.
pFile->Close();
// Clear the current view.
_DeleteAllResourceData();
_DeleteAllPics();
CResourceEnumerator *pEnum;
if (SUCCEEDED(map.CreateEnumerator(RTF_PIC, &pEnum)))
{
CResourceData *pData;
while (S_OK == pEnum->Next(&pData))
{
// TODO: try catch, and free pData?
// Add these resource datas.
_resources.Add(pData);
// And create a pic from them.
CPic *ppic = new CPic();
if (ppic)
{
if (SUCCEEDED(ppic->InitFromResource(pData)))
{
_pics.Add(ppic);
}
else
{
delete ppic;
}
}
}
#ifdef DEBUG
INT_PTR iSizeMemory = 0;
for (INT_PTR i = 0; i < _pics.GetSize(); i++)
{
CPic *ppic = _pics.GetAt(i);
iSizeMemory += ppic->GetMemorySize();
}
TCHAR sz[MAX_PATH];
StringCchPrintf(sz, ARRAYSIZE(sz), TEXT("Memory size of pics: %d"), iSizeMemory);
OutputDebugString(sz);
#endif
SetModifiedFlag(TRUE);
UpdateAllViews(NULL, VIEWUPDATEHINT_RESOURCEMAPCHANGED);
delete pEnum;
}
}
else
{
AfxMessageBox(TEXT("SCI game resources must be called resource.map"), MB_OK | MB_ICONEXCLAMATION);
}
}
}
示例9: OnFileHashed
void CTorrent::OnFileHashed()
{
CFile* pFile = GetFile();
ASSERT(m_TorrentInfo);
if(m_TorrentInfo->IsEmpty()) // are we making a torrent
{
QStringList Shared = theCore->Cfg()->GetStringList("Content/Shared");
Shared.append(theCore->GetIncomingDir());
Shared.append(theCore->GetTempDir());
QList<CTorrentInfo::SFileInfo> Files;
if(CJoinedPartMap* pParts = qobject_cast<CJoinedPartMap*>(pFile->GetPartMap()))
{
QMap<uint64, SPartMapLink*> Links = pParts->GetJoints();
for(QMap<uint64, SPartMapLink*>::iterator I = Links.end(); I != Links.begin();)
{
SPartMapLink* pLink = *(--I);
CFile* pSubFile = pFile->GetList()->GetFileByID(pLink->ID);
if(!pSubFile)
{
LogLine(LOG_DEBUG | LOG_ERROR, tr("A sub file of %1 has been being removed befoure the torrent was created").arg(pFile->GetFileName()));
pFile->TorrentHashed(this, false);
return;
}
CTorrentInfo::SFileInfo File;
QString Root;
QStringList Path = GetRelativeSharedPath(pSubFile->GetFilePath(), Shared, Root).split("/", QString::SkipEmptyParts);
if(!Path.isEmpty())
{
if(Path.count() > 1)
Path.removeFirst();
File.FileName = Path.takeLast();
File.FilePath = Path;
}
else
File.FileName = "unknown";
File.Length = pSubFile->GetFileSize();
Files.append(File);
}
}
if(CFileHashTree* pHashTree = qobject_cast<CFileHashTree*>(m_pHash.data()))
m_TorrentInfo->MakeMetadata(Files, pHashTree->GetPartSize(), QList<QByteArray>(), pHashTree->GetRootHash());
else if(CFileHashSet* pHashSet = qobject_cast<CFileHashSet*>(m_pHash.data()))
m_TorrentInfo->MakeMetadata(Files, pHashSet->GetPartSize(), pHashSet->GetHashSet());
else {
ASSERT(0);
}
if(!pFile->IsPending())
SaveTorrentToFile();
m_pHash->SetHash(m_TorrentInfo->GetInfoHash());
theCore->m_TorrentManager->RegisterInfoHash(m_TorrentInfo->GetInfoHash());
pFile->TorrentHashed(this, true);
}
else // we are importing a torrent
{
bool bMatch = false;
if(CFileHashTree* pHashTree = qobject_cast<CFileHashTree*>(m_pHash.data()))
bMatch = m_TorrentInfo->GetRootHash() == pHashTree->GetRootHash();
else if(CFileHashSet* pHashSet = qobject_cast<CFileHashSet*>(m_pHash.data()))
bMatch = m_TorrentInfo->GetPieceHashes() == pHashSet->GetHashSet();
else {
ASSERT(0);
}
if(bMatch)
{
if(!pFile->IsPending())
SaveTorrentToFile();
m_pHash->SetHash(m_TorrentInfo->GetInfoHash());
theCore->m_TorrentManager->RegisterInfoHash(m_TorrentInfo->GetInfoHash());
}
pFile->TorrentHashed(this, bMatch);
}
}
示例10: Serialize
void CGenericDoc::Serialize(CArchive& ar)
{
TRACE("CGenericDoc::Serialize called\n");
BOOL bCanSerialize = TRUE;
if(ar.IsLoading()) {
#ifdef XP_WIN32
// Determine name of actual document.
CFile *pFile = ar.GetFile();
CString csFile;
if(pFile) {
csFile = pFile->GetFilePath();
}
// Determine if this is the same file that was passed into the
// OnOpenDocument function.
// If so, then we can not read our OLE format.
bCanSerialize = (csFile.CompareNoCase(m_csOpenDocumentFile) != 0);
// However, if they're both empty, then we need to allow this.
if(csFile.IsEmpty() && m_csOpenDocumentFile.IsEmpty()) {
bCanSerialize = TRUE;
}
TRACE("%d = !(%s==%s)\n", bCanSerialize, (const char *)csFile, (const char *)m_csOpenDocumentFile);
#else
// 16 bit can not turn a file handle into a file name.
// If our document name is set, then say we can't serialize.
bCanSerialize = !(m_bOpenDocumentFileSet && !m_csOpenDocumentFile.IsEmpty());
TRACE("%d = !(%d && !%d)\n", m_bOpenDocumentFileSet, !m_csOpenDocumentFile.IsEmpty());
#endif
}
// We can only serialize if we're not looking at a local file which we've opened up.
if(bCanSerialize) {
// Fleshed out for OLE server work.
// The below is the common implementation that should work across the
// board for all versions of the navigator.
// All it does is either read in or write out a URL.
if(GetContext() && GetContext()->IsDestroyed() == FALSE) {
if (ar.IsStoring())
{
TRACE("Storing\n");
// Just shove our current URL into the file.
// Get the current history entry.
History_entry *pHist = SHIST_GetCurrent(&(GetContext()->GetContext()->hist));
if(pHist != NULL && pHist->address != NULL) {
CString csAddress = pHist->address;
ar << csAddress;
TRACE("URL is %s\n", (const char *)csAddress);
}
else {
TRACE("no history!\n");
CString csEmpty;
ar << csEmpty;
}
}
else
{
TRACE("Reading\n");
// Pretty much just read this in as internet shortcut
// format and load it.
CString csLoadMe;
ar >> csLoadMe;
// Do it.
TRACE("URL is %s\n", (const char *)csLoadMe);
GetContext()->NormalGetUrl(csLoadMe);
}
}
else {
TRACE("no context!\n");
if (ar.IsStoring())
{
TRACE("Storing\n");
// Hope that ephemeral data were cached, otherwise, no real
// harm done.
ar << m_csEphemeralHistoryAddress;
}
else
{
TRACE("Reading\n");
CString csDontcare;
ar >> csDontcare;
}
}
// Next in line should be a string identifying the client which wrote
// out the information.
// ALL NUMBERS TO BE CONVERTED TO NETWORK BYTE ORDER, SO WORKS ACROSS PLATFORMS.
CString csNetscapeVersion;
if(ar.IsStoring()) {
// Write out our document version number.
// This is initially 2.0
ar << theApp.ResolveAppVersion();
TRACE("App version is %s\n", (const char *)theApp.ResolveAppVersion());
// Write out any other information for a particular version here,
// prepended by the amount of total bytes to be written.
// Hold all integer values (all XP values) to a size that will
//.........这里部分代码省略.........
示例11: CloseFile
bool CZipArchive::CloseFile(CFile &file)
{
CString temp = file.GetFilePath();
file.Close();
return CloseFile(temp);
}
示例12: Serialize
void CVertexCollection::Serialize(CArchive& Archive, CTriangulation *Triangulation)
{
double x = 0;
double y = 0;
double z = 0;
CVertex *Vertex = NULL;
CString sLine;
if (Archive.IsStoring())
{
for (long VertexIndex = 4; VertexIndex < m_Collection.GetCount(); VertexIndex++)
{
Vertex = (CVertex *)m_Collection[VertexIndex];
sLine.Format(_T(" %.3lf %.3lf %.3lf"),Vertex->m_Coordinate[0],Vertex->m_Coordinate[1], Vertex->m_Coordinate[2]);
Archive.WriteString(sLine);
Archive.WriteString(_T("\n"));
m_VertexNumber++;
}
}
else
{
//Let's check file extension.
CFile *File = Archive.GetFile();
CString FilePath = File->GetFilePath();
char Ext[256];
_splitpath(FilePath, NULL, NULL, NULL, Ext);
//First four verteces are verteces of bounding box/
for (int VertexIndex = 0; VertexIndex < 4; VertexIndex++)
{
Vertex = new CVertex(0, 0, 0, CVertex::BoundingBox);
Vertex->m_Index = m_Collection.Add(Vertex);
}
do
{
if (!sLine.IsEmpty())
{
CString XString;
CString YString;
CString ZString;
int Start = 0;
XString = sLine.Tokenize(_T(" "), Start);
YString = sLine.Tokenize(_T(" "), Start);
ZString = sLine.Tokenize(_T(" "), Start);
sscanf_s(XString,_T("%lf.2"), &x);
sscanf_s(YString,_T("%lf.2"), &y);
sscanf_s(ZString,_T("%lf.2"), &z);
Vertex = new CVertex(x, y, z, CVertex::Standalone);
Vertex->m_Index = m_Collection.Add(Vertex);
if (m_Collection.GetCount() == 5)
{
m_Min.m_Coordinate[0] = x;
m_Min.m_Coordinate[1] = y;
m_Min.m_Coordinate[2] = z;
m_Max.m_Coordinate[0] = x;
m_Max.m_Coordinate[1] = y;
m_Max.m_Coordinate[2] = z;
}
else
{
//todo = min
if (m_Min.m_Coordinate[0] > x)
m_Min.m_Coordinate[0] = x;
if (m_Min.m_Coordinate[1] > y)
m_Min.m_Coordinate[1] = y;
if (m_Min.m_Coordinate[2] > z)
m_Min.m_Coordinate[2] = z;
if (m_Max.m_Coordinate[0] < x)
m_Max.m_Coordinate[0] = x;
if (m_Max.m_Coordinate[1] < y)
m_Max.m_Coordinate[1] = y;
if (m_Max.m_Coordinate[2] < z)
m_Max.m_Coordinate[2] = z;
}
}
if (m_Collection.GetSize() > 100)
break;
}
while(Archive.ReadString(sLine));
//////////////////////////////////////////
m_DeltaX = 0.25 * fabs((m_Max.m_Coordinate[0] - m_Min.m_Coordinate[0]));
m_DeltaY = 0.25 * fabs((m_Max.m_Coordinate[1] - m_Min.m_Coordinate[1]));
m_Min.m_Coordinate[2] = (double)((long)m_Min.m_Coordinate[2]);
//////////////////////////////////////////////
Vertex = (CVertex *)m_Collection[0];
Vertex->m_Coordinate[0] = m_Min.m_Coordinate[0] - 2 * m_DeltaX;
//.........这里部分代码省略.........
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:101,代码来源:VertexCollection.cpp