Esempio n. 1
0
Pathname::Pathname(const char *name)
{
  _fullpath = NULL;
  _path = _filetitle = _extension = _end ="";

  if (name == NULL) SetPathName("*.*");
  else SetPathName(name);
}
Esempio n. 2
0
BOOL CWedDoc::OnNewDocument()

{
	P2N("CWedDoc::OnNewDocument()\r\n");

	if(GetNumOfDocs() > MAX_DOC_LIMIT)
		{
		AfxMessageBox("Too many open documents");
		return FALSE;
		}

	// Go get one
    if (!CDocument::OnNewDocument())
        return FALSE;

	CString num;
	// Find temporary name that is not an existing file
	while(TRUE)
		{
		num.Format("untitled%02d.txt", newcount++);
		if(access(num, 0))
			break;

		// Safety net
		if(newcount > 100)
			break;
		}
	SetPathName(num);
    SetModifiedFlag();
	return TRUE;
}
Esempio n. 3
0
bool CTwiBootProgDoc::SaveFileAs()
{
    CFileDialog dlg(FALSE, NULL, NULL, OFN_HIDEREADONLY, m_strFileTypeFilter, NULL);
    CString FilePath = GetPathName();
    CString FileName = GetTitle();
    if (FilePath.IsEmpty())
        FilePath = FileName;
    dlg.m_ofn.lpstrTitle = FileName;
    dlg.m_ofn.lpstrFile = FilePath.GetBuffer(_MAX_PATH);
    INT_PTR res = dlg.DoModal();
    FilePath.ReleaseBuffer();
    if (res == IDCANCEL)
        return false;
    CString FileExt = dlg.GetFileExt();

    switch(dlg.m_ofn.nFilterIndex)
    {
    case 1:
        m_FileType = ftBinary;
        if (FileExt.IsEmpty())
            FilePath += ".bin";
        break;
    case 2:
        m_FileType = ftIntelHex;
        if (FileExt.IsEmpty())
            FilePath += ".hex";
        break;
    default:
        ASSERT(FALSE);
        return false;
    }
    SetPathName(FilePath);
    SetTitle(FilePath);
    return SaveFile();
}
Esempio n. 4
0
void CKaiDoc::OnFileSave()
{
    // TODO: Add your command handler code here
    if (pco_Doc_->b_IsImported())
    {
        OnFileSaveAs();
        return;
    }

    CString cstr_path = GetPathName();
    if (!cstr_path.IsEmpty())
    {
        CString cstr_ext = PathFindExtension (cstr_path);
        SetPathName (CString (cstr_path.Left (cstr_path.GetLength() - 
                                              cstr_ext.GetLength())) + 
                              _T(".kai"));
    }
    else
    {
        SetTitle (pco_Doc_->str_Title_.data());
    }

    CDocument::OnFileSave();

    if (IsModified())
    {
        SetTitle (CString (pco_Doc_->str_Title_.data()) + _T("*"));
    }

}
bool dTextureNodeInfo::Deserialize (const dScene* const scene, TiXmlElement* const rootNode) 
{
	DeserialiseBase(scene, dNodeInfo, rootNode);

	SetPathName (rootNode->Attribute ("path"));

	return true;
}
Esempio n. 6
0
bool dTextureNodeInfo::Deserialize (TiXmlElement* const rootNode, int revisionNumber) 
{
	DeserialiseBase(dNodeInfo, rootNode, revisionNumber);

	SetPathName (rootNode->Attribute ("path"));

	return true;
}
Esempio n. 7
0
BOOL CStaticDoc::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			if (newName.IsEmpty())
				VERIFY(newName.LoadString(AFX_IDS_UNTITLED));
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			newName += AfxGetStrategyFileExt( );
		}

		if( !AfxDoPromptFileName(newName, bReplace ? IDS_SAVEFILE : IDS_SAVEFILECOPY,
				OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING, FALSE ) )
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			try
			{
				CFile::Remove(newName);
			}
			catch(CException *e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				if( !e->m_bAutoDelete )
					e->Delete();
			}
		}
		return FALSE;
	}

	// reset the title and change the document name
	if (bReplace)
		SetPathName(newName);

	return TRUE;        // success
}
Esempio n. 8
0
BOOL DocRoot::SaveDocument(const char* pszPathName)
  {
  if (gs_Exec.Busy())
    {
    LogError("SysCAD", 0, "Must not be running");
    return False;
    }
  char Fn[512];
  CString TmpFn;
  if (pszPathName==NULL)
    {
    TmpFn=GetTitle();
    pszPathName = TmpFn.GetBuffer(0);
    }
  
  if (strpbrk(pszPathName, ":\\")==NULL)
    {
    strcpy(Fn, PrjFiles());
    strcat(Fn, pszPathName);
    }
  else
    strcpy(Fn, pszPathName);

  CString Ext;
  VERIFY(GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt));
  pchar ext=Ext.GetBuffer(0);
  const int l=strlen(Fn);
  const int el=strlen(ext);
  if (l<=el)
    strcat(Fn, ext);
  else if (_stricmp(&Fn[l-el], ext)!=0)
    {
    if (Fn[l-el]=='.')
      Fn[l-el]=0; //"old" or "incorect" extension needs to be replaced
    strcat(Fn, ext);
    }

  FILE* pFile= fopen(Fn, "wt");
  flag b=(pFile!=NULL);

  if (b)
    b=WriteDocument(Fn, pFile);

  if (pFile) 
    fclose(pFile);
  if (b)
    {
    SetPathName(Fn);
    SetModifiedFlag(FALSE);
    gs_pCmd->Print("%s - Saved\n", Fn);
    }
  else
    {
    gs_pCmd->Print("%s - NOT SAVED\n", Fn);
    }
  return b;
  }
void CRapiFileDialog::OnUp( wxCommandEvent &event )
{
    wxFileName newfname=m_pathname;
    if(newfname.GetDirCount()>0)
    {
        newfname.RemoveLastDir();
    }

    SetPathName(newfname.GetFullPath());
}
void CRapiFileDialog::OnBack( wxCommandEvent &event )
{
    if(m_history.size()==0)
    {
        return;
    }
    
    wxString strLast=m_history.back();
    m_history.pop_back();
    SetPathName(strLast,false);
}
Esempio n. 11
0
BOOL CBTGDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	Reset();

	SetPathName("Untitled", FALSE);

	return TRUE;
}
Esempio n. 12
0
BOOL CMyPaintDoc::OnOpenDocument(LPCTSTR name) {
  PixRect *image = PixRect::load(theApp.m_device, ByteInputFile(name));

  theApp.AddToRecentFileList(name);

  OnNewDocument();
  setImage(image);
  FileNameSplitter info(name);
  SetTitle(info.getFileName().cstr());
  SetPathName(name);
  setFileImage();
  return TRUE;
}
void CRapiFileDialog::OnFileListItemSelected( wxListEvent &event )
{
    long data=GetFileList()->GetItemData(event.GetIndex());
    if(data<0 || data>=(long)m_currentpaths.size())
    {
        return;
    }

    if(m_currentpaths[data].Last()!=wxT('\\'))
    {
        SetPathName(m_currentpaths[data]);
    }
}
Esempio n. 14
0
void CColorEyeIDoc::saveTxtDlg(LPCTSTR FileFilter)
{
    CFileDlg aFileDialog (FALSE, "txt", "*.txt", OFN_SHAREAWARE, FileFilter);
    
    int nID = aFileDialog.DoModal();
    if (nID == IDOK)
    {
        saveTxtFile(aFileDialog.GetPathName());
        SetPathName(aFileDialog.GetPathName());
        SetTitle(aFileDialog.GetFileName());
    
        SetModifiedFlag(FALSE);
    }        
}
Esempio n. 15
0
BOOL CColorEyeIDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
    if (!CDocument::OnOpenDocument(lpszPathName))
        return FALSE;    
    // TODO: Add your specialized creation code here
    //點兩下會執行這個
    OnNewDocument();
//     OpenOmdFile(lpszPathName);
    SetPathName(lpszPathName);
    SetTitle(lpszPathName);
    SetModifiedFlag(FALSE);    

    UpdateAllViews(NULL);  //更新畫面
    return TRUE;
}
void CRapiFileDialog::OnFileListItemActivated( wxListEvent &event )
{
    long data=GetFileList()->GetItemData(event.GetIndex());
    if(data<0 || data>=(long)m_currentpaths.size())
    {
        return;
    }

    bool bDone=m_currentpaths[data].Last()!=wxT('\\');
    
    SetPathName(m_currentpaths[data]);
    if(bDone)
    {
        EndModal(wxID_OK);
    }
}
Esempio n. 17
0
BOOL DocRoot::OpenDocument(const char* pszPathName)
  {
  if (gs_Exec.Busy())
    {
    LogError("SysCAD", 0, "Must not be running");
    return False;
    }

  SetModifiedFlag(FALSE);
  gs_pPrj->bDocChanged=0;
  
  char Fn[512];
  if (strpbrk(pszPathName, ":\\")==NULL)
    {
    strcpy(Fn, PrjFiles());
    strcat(Fn, pszPathName);
    }
  else
    strcpy(Fn, pszPathName);
  CString Ext;
  VERIFY(GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt));
  //GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt);
  pchar ext=Ext.GetBuffer(0);
  const int l=strlen(Fn);
  const int el=strlen(ext);
  if (l<=el || (_stricmp(&Fn[l-el], ext)!=0 && Fn[l-el]!='.'))
    strcat(Fn, ext);

  FILE* pFile= fopen(Fn, "rt");
  flag b=(pFile!=NULL);
   
  if (b && !feof(pFile))
    b=ReadDocument(Fn, pFile);

  if (pFile) 
    fclose(pFile);
  if (b)
    {
    SetPathName(Fn);
    //LogNote("Document", 0, "Loaded : %s", Fn); Who really wants to know?
    }
  else
    {
    LogError("Document", 0, "NOT Loaded : %s", Fn);
    }
  return b;
  }
bool CCALCViewWinDoc::SaveFile(CString path)
{
	std::stringstream ss;
	
	for (int i = 0; i < NUM_REGISTERS; ++i) {
		try {
			std::string reg_name = _machine.Index_To_Name_Memory(i);
			
			Mem_Status *reg = _machine.Index_To_Memory(i);
			std::string reg_value = reg->Get_Configuration();
			
			// Make sure the parameter is configurable
			if (reg->Can_Config()) {
				
				// Add space at the beginning if it's not NAME
				if (i != NAME)	
					reg_name = " " + reg_name;
				
				// Add padding after regname
				while (reg_name.size() < 8)
					reg_name = reg_name + " ";
			
				// Add remainder of string
				ss << reg_name << " = " << reg_value << std::endl;
			}
		}
		catch (...) {
		
		}
	}
	
	// Add the last line
	ss << "END" << std::endl;
	
	std::ofstream f;
	f.open(LPCTSTR(path), std::ios::out);
	f.write(ss.str().c_str(), ss.str().size());
	f.close();
	
	// Update path
	SetPathName(path, true);
	SetModifiedFlag(false);

	return true;
}
Esempio n. 19
0
void CColorEyeIDoc::openTxtDlg(LPCTSTR FileFilter)
{
    CFileDlg aFileDialog (TRUE, "txt", "*.txt", OFN_SHAREAWARE | OFN_OVERWRITEPROMPT, FileFilter);
    
    int nID = aFileDialog.DoModal();
    if (nID == IDOK)
    {
//         m_docDNA.Empty();
        m_docRNA.Empty();
        m_docFileHead.Empty();
        SetModifiedFlag(FALSE);
        UpdateAllViews(NULL);

        openTxtFile(aFileDialog.GetPathName());    
        SetPathName(aFileDialog.GetPathName());
        SetTitle(aFileDialog.GetFileName());
    }
}
Esempio n. 20
0
BOOL CBonfireDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	if (m_pXFile->m_bSaved && !m_pXFile->m_bNew && GetPathName() == lpszPathName)
		return TRUE;
	else if (m_xTextBuffer.GetReadOnly())
		return FALSE;
	
	// temporarily remove the file from modify watch
	RemoveFileWatch();

	m_xTextBuffer.SaveToFile(lpszPathName);
	SetPathName(lpszPathName);
	
	// add the file back to modify watch
	AddToFileWatch();

	return TRUE;
}
Esempio n. 21
0
BOOL CMyPaintDoc::OnSaveDocument(LPCTSTR name) {
  FileNameSplitter info(name);
  if(info.getExtension() == _T(".jpg")) {
    m_image->writeAsJPG(ByteOutputFile(info.setExtension( _T("jpg" )).getFullPath()));
  } else if(info.getExtension() == _T(".tiff")) {
    m_image->writeAsTIFF(ByteOutputFile(info.setExtension(_T("tiff")).getFullPath()));
  } else if(info.getExtension() == _T(".bmp")) {
    m_image->writeAsBMP(ByteOutputFile(info.setExtension( _T("bmp" )).getFullPath()));
  } else if(info.getExtension() == _T(".png")) {
    m_image->writeAsPNG(ByteOutputFile(info.setExtension( _T("png" )).getFullPath()));
  } else {
    throwException(_T("Unknown fileformat:%s"), info.getExtension().cstr());
  }
  SetTitle(info.getFileName().cstr());
  SetPathName(name);
  setFileImage();
  return TRUE;
}
Esempio n. 22
0
void CNewPackingToolDoc::OnFileSaveAs()
{
	static CMainFrame*  pFrame = (CMainFrame*)AfxGetMainWnd();

	int index = pFrame->GetCurIndex();

	if (index == -1)
		return;

	CNewPackingToolView* pView = (CNewPackingToolView*)pFrame->GetActiveView();

	// 현재 화면 View 저장.
	CString str;
	pView->GetWindowText(str);
	SaveData(index, str.GetBuffer(0));

	CFileDialog dlg( FALSE, NULL, "*.bin", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
		"Binary 파일|*.bin; *.beff; *.befl; *.bmhm; *.bsad|모든 파일 (*.*)|*.*||", NULL );

	if ( dlg.DoModal() == IDOK )
	{
		CString lpszPathName = dlg.GetPathName();

		// 파일 저장.
		m_FileMng.SaveAs(index, lpszPathName, pFrame->m_bUseAES);
		pFrame->ChangeFile(index, m_FileMng.GetFileName(index));

		// 결과출력
		CString outStr;
		outStr.Format("Save File ( %s ) is Complete. \r\n", dlg.GetFileName());
		pFrame->AddOutStr(outStr);

		SetPathName(dlg.GetPathName(), TRUE);
		SetModifiedFlag(FALSE);

		static CEdit* pEdit   = &(pView->GetEditCtrl());

		pEdit->SetModify(FALSE);
		pView->GetDocument()->SetTitle(dlg.GetFileName());

	}
}
Esempio n. 23
0
BOOL CDIPDemoDoc::OnOpenDocument ( LPCTSTR
                                   lpszPathName )
{
    DeleteContents();
    // 更改光标形状
    BeginWaitCursor();

    // 读取图像并附加到m_Image上
    if ( !m_Image.AttachFromFile ( lpszPathName ) )
    {
        EndWaitCursor();
        AfxMessageBox ( L"打开文件时出错!请确保正确的位图(*.bmp)文件类型。" );
        return FALSE;
    }

    // 恢复光标形状
    EndWaitCursor();

    // 判断读取成功否
    if ( !m_Image.m_lpData )
    {
        // 失败,可能非BMP格式
        CString strMsg;
        strMsg = L"读取图像时出错!可能是不支持该类型的图像文件!";
        // 提示出错
        MessageBox ( NULL, strMsg, L"系统提示",
                     MB_ICONINFORMATION | MB_OK );
        // 返回FALSE
        return FALSE;
    }

    Init(); //对图像的尺寸和调色板信息进行初始化
    // 设置文件名称
    SetPathName ( lpszPathName );
    // 拷贝当前m_Image到m_OImage
    m_OImage = m_Image;
    // 初始化胀标记为FALSE
    SetModifiedFlag ( FALSE );
    // 返回TRUE
    return TRUE;
}
GoodsModelManager::GoodsModelManager()
{
	m_DisplayModel = NULL;
	//模型系统初始化
	CGameModelManager::InitInstance();	
	CGameModelManager::GetInstance()->SetTextureShareFolder(Setting::GetInstance()->m_szTextureSharFolder);
	m_GameModelManager = CGameModelManager::GetInstance();
	//如果为空需要重新创建
	if(m_GameModelManager == NULL)
	{
		MessageBox(NULL,"CGameModelManager 未初始化!","Error",MB_OK|MB_ICONERROR);
		VERIFY(m_GameModelManager);
	}
	m_Camera	= NULL;
	m_Frustum	= new render::Frustum;
	VERIFY(m_Frustum);
	SetPathName(Setting::GetInstance()->m_szGoodsModelFolder);
	SetOpenModelFileName("");
	//重置模型显示位置和角度
	ResetPosAndRot();
}
Esempio n. 25
0
BOOL CDocument::DoSave( LPCTSTR lpszPathName, BOOL bReplace )
/***********************************************************/
{
    CString strPathName;
    if( lpszPathName != NULL ) {
        strPathName = lpszPathName;
    } else {
        CWinApp *pApp = AfxGetApp();
        ASSERT( pApp != NULL );
        if( !pApp->DoPromptFileName( strPathName, AFX_IDS_SAVEFILE, OFN_PATHMUSTEXIST,
                                     FALSE, m_pDocTemplate ) ) {
            return( FALSE );
        }
    }
    if( !OnSaveDocument( strPathName ) ) {
        return( FALSE );
    }
    if( bReplace ) {
        SetPathName( strPathName );
    }
    return( TRUE );
}
Esempio n. 26
0
BOOL CPLViewerDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
    // recycle document
    DeleteContents();

    m_pDib = new PLWinBmpEx;

    // have PaintLib perform I/O instead of Serialization
    bool bRet = true;
    try
    {
        // Jo Hagelberg 15.4.99: added "this" for progress notification
        thisApp.GetDecoder()->MakeBmpFromFile(lpszPathName, m_pDib, PLPixelFormat::DONTCARE, this);
    }
    catch (PLTextException e)
    {
        AfxMessageBox(e);
        DeleteContents();
        bRet = false;
    }

    if (bRet)
    {
        SetPathName(lpszPathName);
        SetModifiedFlag(false);      // start off with unmodified
        char *cp = strrchr(lpszPathName,'\\');
        if (cp) // establish this image's directory as our new wd
        {
            *cp = '\0';
            SetCurrentDirectory(lpszPathName);
            // pretend we did not touch that string
            *cp = '\\';
        }
    }

    return bRet;    // Belgian resolution enhancement technology :-)
}
Esempio n. 27
0
GenericArchive::OpenResult AcuArchive::Open(const WCHAR* filename,
    bool readOnly, CString* pErrMsg)
{
    CString errMsg;

    //fIsReadOnly = true;     // ignore "readOnly"

    errno = 0;
    fFp = _wfopen(filename, L"rb");
    if (fFp == NULL) {
        errMsg.Format(L"Unable to open %ls: %hs.", filename, strerror(errno));
        goto bail;
    }

    {
        CWaitCursor waitc;
        int result;

        result = LoadContents();
        if (result < 0) {
            errMsg.Format(L"The file is not an ACU archive.");
            goto bail;
        } else if (result > 0) {
            errMsg.Format(L"Failed while reading data from ACU archive.");
            goto bail;
        }
    }

    SetPathName(filename);

bail:
    *pErrMsg = errMsg;
    if (!errMsg.IsEmpty())
        return kResultFailure;
    else
        return kResultSuccess;
}
Esempio n. 28
0
BOOL CDocument::OnSaveDocument( LPCTSTR lpszPathName )
/****************************************************/
{
    CFileException ex;
    CFile *pFile = GetFile( lpszPathName, CFile::modeCreate | CFile::modeWrite, &ex );
    if( pFile == NULL ) {
        ReportSaveLoadException( lpszPathName, &ex, TRUE, AFX_IDP_FAILED_TO_SAVE_DOC );
        return( FALSE );
    }
    try {
        CArchive ar( pFile, CArchive::store );
        Serialize( ar );
        ar.Close();
        SetPathName( lpszPathName );
        SetTitle( pFile->GetFileTitle() );
        ReleaseFile( pFile, FALSE );
    } catch( CException *pEx ) {
        ReportSaveLoadException( lpszPathName, pEx, TRUE, AFX_IDP_FAILED_TO_SAVE_DOC );
        ReleaseFile( pFile, TRUE );
        return( FALSE );
    }
    SetModifiedFlag( FALSE );
    return( TRUE );
}
Esempio n. 29
-1
BOOL CEtsEodManagerDoc::OnNewDocument()
{
	if(!OnOpenDocument(g_App.m_strCurrentReportFilePath))
		return FALSE;

	SetPathName(g_App.m_strCurrentReportFilePath);
	return TRUE;
}
Esempio n. 30
-10
void CbelaviewDoc::OnReload() 
{
	// TODO: Add your command handler code here
	CString pname = GetPathName();
	if(pname.GetLength()>0)
	{
		OnNewDocument();
		SetPathName(pname,FALSE);
		OnOpenDocument(pname);
	}
}