示例#1
0
bool CProperties::CreatePathToFile(LPCTSTR pszDir) 
{
  // Create intermediate directories
#ifdef _WIN32
  const TCHAR cSep='\\';
#else // UNIX
  const TCHAR cSep='/';
#endif
  for(LPCTSTR c=_tcschr(pszDir,cSep);c;c=_tcschr(c+1,cSep)){
#ifdef _WIN32
    if(c==pszDir+2 && _istalpha(pszDir[0]) && _TCHAR(':')==pszDir[1]){
      continue; // don't attempt to create "C:"
    }
#endif
    String strDir(pszDir,c-pszDir);
    struct _stat buf;
    if(!(0==_tstat(strDir,&buf) && (S_IFDIR&buf.st_mode))){
      // Need to create directory
      bool b=(0==_tmkdir(strDir));
      TRACE(_T("Create directory %s rc=%d\n"),(LPCTSTR)strDir,b);
      if(!b){
        return false;
      }
    }
  }
  return true;
}
示例#2
0
文件: Model.cpp 项目: DT85/Assimilate
void CModelPropPage::OnCheckMakeskel() 
{
	UpdateData(DIALOG_TO_DATA);

	// first time we turn it on, we should make up a reasonable default name...

	if (m_bMakeSkel && m_strSkelPath.IsEmpty())
	{
		// basically I'm just going to use the dir name as the GLA name base as well...

		CString strSuggestedPath(m_model->GetPath());			// eg. "models/players/blah/root"
		int iLoc = strSuggestedPath.ReverseFind('/');
		if (iLoc>=0)
		{
			strSuggestedPath = strSuggestedPath.Left(iLoc);		// eg. "models/players/blah"

			iLoc = strSuggestedPath.ReverseFind('/');
			if (iLoc >= 0)
			{
				CString strDir(strSuggestedPath.Mid(iLoc+1));	// eg. "blah"

				strSuggestedPath += "/";
				strSuggestedPath += strDir;						// eg. "models/players/blah/blah"

				m_strSkelPath = strSuggestedPath;

				UpdateData(DATA_TO_DIALOG);
			}
		}
	}

	HandleItemGreying();	
}
//////////////////////////////////////////////////////////////////////////
// 全局函数,创建多级目录
bool CreateMultipleDirectory(LPCTSTR szPath)
{
	CString strDir(szPath); // 存放要创建的目录字符串
	// 确保以'\'结尾以创建最后一个目录
	if (strDir.GetAt(strDir.GetLength()-1)!=_T('\\'))
	{
		strDir.AppendChar(_T('\\'));
	}
	std::vector<CString> vPath;// 存放每一层目录字符串
	CString strTemp;// 一个临时变量,存放目录字符串
	bool bSuccess = false;// 成功标志
	// 遍历要创建的字符串
	for (int i=0;i<strDir.GetLength();++i)
	{
		if (strDir.GetAt(i) != _T('\\')) 
		{// 如果当前字符不是'\\'
			strTemp.AppendChar(strDir.GetAt(i));
		}
		else 
		{// 如果当前字符是'\\'
			vPath.push_back(strTemp);// 将当前层的字符串添加到数组中
			strTemp.AppendChar(_T('\\'));
		}
	}
	// 遍历存放目录的数组,创建每层目录
	std::vector<CString>::const_iterator vIter;
	for (vIter = vPath.begin(); vIter != vPath.end(); vIter++) 
	{
		// 如果CreateDirectory执行成功,返回true,否则返回false
		bSuccess = CreateDirectory(*vIter, NULL) ? true : false;    
	}
	return bSuccess;
}
void T3kSoftlogicDlg::on_BtnLoad_clicked()
{
    if( !checkModified() )
        return;

    QString strDir( QApplication::applicationDirPath() );
    if( !m_strLoadedModelPathName.isEmpty() )
    {
        int nBP = m_strLoadedModelPathName.lastIndexOf( '/' );
        strDir = m_strLoadedModelPathName.left( nBP+1 );
    }

    QString strLoad = QFileDialog::getOpenFileName( this, "Open", strDir, "Files(*.hsk)" );

    if( !strLoad.isEmpty() )
    {
        loadModel( strLoad );

        m_pTabPanelWidget->updateUIFromData();
        T3kCommonData::instance()->resetCalibrationData();
        onUpdatePrewview();

        m_pTabKeyDesignWidget->refresh();
        //m_wndTab.ResetNotify();
    }
}
示例#5
0
void COpenSavedDlg::GetName(const char *pszDir, CString &strName)
{
	strName.Empty();

	CString strDir(pszDir);
	int nIndex = strDir.Find('-');
	if (nIndex == -1)
		return;

	strName = strDir.Mid(nIndex+1);
}
void T3kSoftlogicDlg::on_BtnSave_clicked()
{
    m_pTabPanelWidget->updateDataFromUI();

    T3kCommonData::KeyDataMode eMode = T3kCommonData::instance()->getKeyDataMode();
    T3kCommonData::instance()->setKeyDataMode( T3kCommonData::KeyDataModeNormal );

    QString strPanelName = T3kCommonData::instance()->getKeys().getPanelName();

    T3kCommonData::instance()->setKeyDataMode( eMode );
    if( strPanelName.isEmpty() )
    {
        QMessageBox msg( QMessageBox::Critical, "Error", "Panel Name is required.", QMessageBox::Ok, this );
        msg.exec();
        setFocusPanelName();
        return;
    }

    QString strModelName( m_strLoadedModelPathName.right( m_strLoadedModelPathName.length() - m_strLoadedModelPathName.lastIndexOf('/') - 1 ) );
    int nIdx = strModelName.indexOf( '.' );
    strModelName = strModelName.left( nIdx );

    if( m_strLoadedModelPathName.isEmpty() || strModelName != strPanelName )
    {
        QString strFileName = strPanelName;
        strFileName += ".hsk";

        QString strDir( QApplication::applicationDirPath() );
        if( !m_strLoadedModelPathName.isEmpty() )
        {
            int nBP = m_strLoadedModelPathName.lastIndexOf( '/' );
            strDir = m_strLoadedModelPathName.left( nBP+1 );
        }

        QString strSave = QFileDialog::getSaveFileName( this, "Save", strDir, "Files(*.hsk)", &strFileName );
        if( strSave.isEmpty() )
            return;

        m_strLoadedModelPathName = strSave;
    }

    saveModel( m_strLoadedModelPathName );
    QString strLoad = m_strLoadedModelPathName;
    loadModel( strLoad );

    m_pTabPanelWidget->updateUIFromData();
    onUpdatePrewview();

    T3kCommonData::instance()->resetCalibrationData();

    //m_wndTab.ResetNotify();
}
示例#7
0
BOOL PathHelper::RemoveMultipleDirectory(const std::wstring& strPath)
{
    //存放要删除的目录字符串
    std::wstring strDir(strPath);

    //确保以'\'结尾以删除最后一个目录
    if (strDir[strDir.length() - 1] != (L'\\'))
    {
        strDir += L'\\';
    }

    //存放每一层目录字符串
    std::vector<std::wstring> vecPath;
    //一个临时变量,存放目录字符串
    std::wstring strTemp;
    //成功标志
    BOOL bSuccess = FALSE;

    //遍历要删除的字符串
    for (UINT i=0; i<strDir.length(); ++i)
    {
        if (strDir[i] != L'\\')
        {
            //如果当前字符不是'\\'
            strTemp += strDir[i];
        }
        else
        {
            //如果当前字符是'\\',将当前层的字符串添加到数组中
            vecPath.push_back(strTemp);
            strTemp += strDir[i];
        }
    }

    //遍历存放目录的数组,删除每层目录,从最深的目录开始删除,进行逆向访问
    std::vector<std::wstring>::const_reverse_iterator iter;
    for (iter = vecPath.rbegin(); iter != vecPath.rend(); iter++)
    {
        //如果RemoveDirectory执行成功,返回true,否则返回FALSE
        ///BOOL bResult = iter->find('\\');
        std::wstring::size_type iFindPos = iter->find(L'\\');
        if (std::wstring::npos != iFindPos)
        {
            bSuccess = RemoveDirectoryW(iter->c_str()) ? true : FALSE;
        }
    }

    return bSuccess;
}
示例#8
0
std::string Filesystem::getCurrentRobotDirectory(std::string name)
{
	if (name.length() <= 0)
		name = "unnamed";

	char *dir;
	errno_t err = _dupenv_s(&dir, NULL, "APPDATA");

	if (err)
		throw "Failed to get AppData directory!";

	std::string strDir(dir);
	free(dir);

	return strDir + '\\' + ROBOT_APPDATA_DIRECTORY + '\\' + name + '\\';
}
示例#9
0
// 指定ディレクトリの情報を登録する
BOOL CFileTree::RegisterFileTree(LPCSTR lpszPath)
{
    izanagi::tool::CString strDir(PathFindFileName(lpszPath));
    
    // 末尾の'/'を消す
    {
        size_t nStrLen = strlen(strDir);
        int nDelimiterPos_0 = strDir.reverse_find(DELIMITER_0);
        int nDelimiterPos_1 = strDir.reverse_find(DELIMITER_1);

        if ((nStrLen == nDelimiterPos_0)
            || (nStrLen == nDelimiterPos_1))
        {
            LPCSTR str = strDir;
            const_cast<CHAR*>(str)[nStrLen] = '\0';
        }
    }

    // 自分自身をチェック
    {
        WIN32_FIND_DATA dataFile;
        HANDLE hIter = FindFirstFile(strDir, &dataFile);

        VRETURN(hIter != NULL);
        VRETURN(dataFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
    }

    // TODO
    m_FileList.reserve(100);

    // TODO
    m_TmpDirList.reserve(10);
    m_TmpDirList.push_back(strDir);

    while (m_TmpDirList.size() > 0) {
        std::vector<izanagi::tool::CString>::iterator it = m_TmpDirList.begin();
        IZ_ASSERT(it != m_TmpDirList.end());

        const izanagi::tool::CString& strDir = *it;
        RegisterFileTreeInternal(strDir);

        m_TmpDirList.erase(it);
    }

    return TRUE;
}
示例#10
0
CString CApplication::GetAppDirectory()
{
    DWORD  dwNameLength = 512;
    WCHAR* moduleName = new WCHAR[dwNameLength];

    while( dwNameLength == ::GetModuleFileNameW(0, moduleName, dwNameLength) )
    {
        delete[] moduleName;
        dwNameLength *= 2;
        moduleName = new WCHAR[dwNameLength];
    }

    CString strDir(moduleName);
    delete[] moduleName;

    strDir.Delete(strDir.ReverseFind(L'\\') + 1, strDir.GetLength());
    return strDir;
}
示例#11
0
void makeGoodData()
{
	for (int i=0;i<10;i++)
	{
		//double d=(double)i;
		Raw *data=myColondata4(512,512,50,0.9+i*0.01);
		RawImage *outdata=new RawImage();
		char file_no[4];
		int filen = i;
		string strDir("D:\\goodata0.9");
		itoa(filen, file_no, 10);//把数字存储为char的数组
		strDir += file_no;//string是标准库类型,可以直接与char的数组进行+号连接
		strDir += ".raw";
		const char *cstr = strDir.c_str();
		outdata->writenormal(*data,cstr);
		delete data;
	}
}
示例#12
0
BOOL PathHelper::CreateMultipleDirectory(const std::wstring& strPath)
{
    //存放要创建的目录字符串
    std::wstring strDir(strPath);

    //确保以'\'结尾以创建最后一个目录
    if (strDir[strDir.length() - 1] != (L'\\'))
    {
        strDir += L'\\';
    }

    //存放每一层目录字符串
    std::vector<std::wstring> vecPath;
    //一个临时变量,存放目录字符串
    std::wstring strTemp;
    //成功标志
    BOOL bSuccess = FALSE;

    //遍历要创建的字符串
    for (UINT i=0; i<strDir.length(); ++i)
    {
        if (strDir[i] != L'\\')
        {
            //如果当前字符不是'\\'
            strTemp += strDir[i];
        }
        else
        {
            //如果当前字符是'\\',将当前层的字符串添加到数组中
            vecPath.push_back(strTemp);
            strTemp += strDir[i];
        }
    }

    //遍历存放目录的数组,创建每层目录
    std::vector<std::wstring>::const_iterator iter;
    for (iter = vecPath.begin(); iter != vecPath.end(); iter++)
    {
        //如果CreateDirectory执行成功,返回true,否则返回FALSE
        bSuccess = CreateDirectoryW(iter->c_str(), NULL) ? true : FALSE;
    }

    return bSuccess;
}
示例#13
0
static void DiffDir_WalkDir(LPCTSTR strDirIn, CDiffer& D)
{
	std::string strDir(strDirIn);
	if( '\\' != (strDir.at(strDir.length()-1)) )
	{
		strDir.append("\\");
	}

	std::string strSearch(strDir);
	strSearch.append("*");

	//printf("Scanning \"%s\"...\n", strDir.c_str());

	WIN32_FIND_DATA FD;
	HANDLE hFind = FindFirstFile(strSearch.c_str(), &FD);
	if(INVALID_HANDLE_VALUE == hFind)
		return;

	do
	{
		//If we have a directory we behave a little differently.
		if(((FILE_ATTRIBUTE_DIRECTORY&FD.dwFileAttributes) != 0))
		{
			//printf("Found directory.\n");
			if('.' == FD.cFileName[0])
				continue;

			std::string strSubDir(strDir);
			strSubDir.append(FD.cFileName);
			DiffDir_WalkDir(strSubDir.c_str(), D);
		}
		else
		{
			std::string strFile(strDir);
			strFile.append(FD.cFileName);
			//printf("Found %s.\n", strFile.c_str());
			D.AddFile(strFile.c_str(), FD);
		}

	}while(FindNextFile(hFind, &FD));

	FindClose(hFind);
}
void T3kSoftlogicDlg::closeEvent(QCloseEvent *)
{
    if( isModified() )
    {
        QMessageBox msg( QMessageBox::Question, "Warning", "Would you like to save this data?", QMessageBox::Yes|QMessageBox::No, this );
        if( msg.exec() == QMessageBox::Yes )
        {
            m_pTabPanelWidget->updateDataFromUI();

            T3kCommonData::KeyDataMode eMode = T3kCommonData::instance()->getKeyDataMode();
            T3kCommonData::instance()->setKeyDataMode( T3kCommonData::KeyDataModeNormal );
            QString strPanelName = T3kCommonData::instance()->getKeys().getPanelName();
            T3kCommonData::instance()->setKeyDataMode( eMode );
            if( strPanelName.isEmpty() )
            {
                QMessageBox msg( QMessageBox::Critical, "Error", "Panel Name is required.", QMessageBox::Ok, this );
                msg.exec();
                setFocusPanelName();
                return;
            }

            QString strModelName( m_strLoadedModelPathName.right( m_strLoadedModelPathName.length() - m_strLoadedModelPathName.lastIndexOf('/') - 1 ) );
            int nIdx = strModelName.indexOf( '.' );
            strModelName = strModelName.left( nIdx );

            if( m_strLoadedModelPathName.isEmpty() || strModelName != strPanelName )
            {
                QString strFileName = strPanelName;
                strFileName += ".hsk";

                QString strDir( QApplication::applicationDirPath() );
                if( !m_strLoadedModelPathName.isEmpty() )
                {
                    int nBP = m_strLoadedModelPathName.lastIndexOf( '/' );
                    strDir = m_strLoadedModelPathName.left( nBP+1 );
                }

                QString strSave = QFileDialog::getSaveFileName( this, "Save", strDir, "Files(*.hsk)", &strFileName );
                if( strSave.isEmpty() )
                    return;

                m_strLoadedModelPathName = strSave;
            }

            saveModel( m_strLoadedModelPathName );

            T3kCommonData::instance()->resetCalibrationData();

            //m_wndTab.ResetNotify();
        }
    }

    m_pTabKeyDesignWidget->close();
    m_pTabLogicDesignWidget->close();
    m_pTabCalibrationWidget->close();

    QRect rc( geometry() );
    QString str = QString("%1,%2,%3,%4").arg(rc.left()).arg(rc.top()).arg(rc.right()).arg(rc.bottom());
    QSettings settings( "Habilience", "T3kSoftlogic" );
    settings.beginGroup( "Windows" );
    settings.setValue( "Main_Pos", str );
    settings.setValue( "Main_Show", isMaximized() ? WND_MAX : isMinimized() ? WND_MIN : isHidden() ? WND_HIDE : WND_SHOW );
    settings.endGroup();

    QString strRecentModelName = m_strLoadedModelPathName;//m_SoftKey.GetPanelName();
    settings.beginGroup( "RECENT MODEL" );
    settings.setValue( "MODEL_NAME", strRecentModelName );
    settings.endGroup();
}
示例#15
0
void CPlayerView::AddToPlayList( const CString& strFileName ) 
{
	CString strExt( strFileName );
	CString strDir( strFileName );
	CString strCurrentDir;

	int nPos;

	nPos = strExt.ReverseFind( '.' );

	if ( nPos > 0 ) 
	{
		strExt = strExt.Mid( nPos + 1 );
	}


	nPos = strDir.ReverseFind( _T( '\\' ) );

	if ( nPos > 0 ) 
	{
		strDir = strDir.Left( nPos );
	}
	

	char lpszCurDir[ MAX_PATH + 1 ] = {'\0',};
	
	// Get current directory
	_getcwd( lpszCurDir, sizeof( lpszCurDir ) );

	if ( 0 == strExt.CompareNoCase( _T( "M3U" ) ) )
	{
		// go to the directory
		if ( 0 == _tchdir( strDir ) )
		{
			// open the playlist
			FILE* pFile = CDexOpenFile( CUString( strFileName ), _W( "rt" ) );

			if ( NULL != pFile )
			{
				char lpszLine[ 8192 ] = {'\0',};

				// read the lines in the playlist file
				while ( NULL != fgets( lpszLine, sizeof( lpszLine ), pFile ) )
				{
					if ( '\n' == lpszLine[ strlen( lpszLine ) -1 ] )
					{
						lpszLine[ strlen( lpszLine ) -1 ] = '\0';
					}

					// skip extended info
					if ( '#' != lpszLine[0] )
					{
						CString strEntry( lpszLine );

						int nPos = 0;

						if ( strDir.Find( _T( ":\\" ) ) < 0 ) 
						{
							if ( 0 == ( nPos = strEntry.Find( _T( ".\\" ) ) ) )
							{
								strEntry = strDir + strEntry.Mid( 1 );
							}
							else
							{
								strEntry = strDir + _T( "\\" ) + strEntry;
							}
						}

						AddStringToPlayList( strEntry );
					}
				}

				// close the playlist file
				fclose( pFile );
			}
		}

	}
	else if ( 0 == strExt.CompareNoCase( _T( "PLS" ) ) )
	{
		CIni	plsIni;
		int		nNumEntries = 0;
		CString	strEntry;
		CString	strNumber;
		int		i = 0;
		

		// go to the directory
		if ( 0 == _tchdir( strDir ) )
		{

			plsIni.SetIniFileName( CUString( strFileName ) );

			nNumEntries = plsIni.GetValue(	_T( "playlist" ),
											_T( "NumberOfEntries" ), 
											nNumEntries );

			for ( i = 1; i <= nNumEntries; i++ )
			{
				strNumber.Format( _T( "File%d"), i );

				strEntry = plsIni.GetValue( CUString( _W( "playlist" ) ),
											CUString( strNumber ),
											_W( "" ) );


				if ( !strEntry.IsEmpty() )
				{

					int nPos = 0;

					if ( strDir.Find( _T( ":\\" ) ) < 0 ) 
					{
						if ( 0 == ( nPos = strEntry.Find( _T( ".\\" ) ) ) )
						{
							strEntry = strDir + strEntry.Mid( 1 );
						}
						else
						{
							strEntry = strDir + _T( "\\" ) + strEntry;
						}
					}
					AddStringToPlayList( strEntry );
				}
			}
		}
	}
	else
	{
		AddStringToPlayList( strFileName );
	}

	// switch back to the current directory
	chdir( lpszCurDir );

}
示例#16
0
int joinDir(const char *sourceDir, const char *extName)
{
    stJAndSHeader *joinHdr = NULL;
    FILE *fileHdl = NULL;
    char
        destName[_MAX_DIR],
        tempName[_MAX_DIR];
    char outmode[] = "wb6 ";
    short  nErr;

    // Clear any outstanding errors
    errno = EZERO;

    // Get memory for the join header structure
    if ((joinHdr = (stJAndSHeader*)malloc(sizeof(stJAndSHeader))) != NULL)
    {
        // Populate the header with all the match files
        if (genHeader (sourceDir, "", extName, joinHdr, 1)) //@3 directory
        {
            // Clear any outstanding errors
            errno = EZERO;

            // Generate the destination name
            sprintf (destName, "%s%s", sourceDir, extName);

            // Open the join file...
            if ((fileHdl = fopen (destName, "wb")) != NULL)
            {
                // ... and join in all the files.
                writeHeader ( joinHdr, fileHdl);
                concatFiles ( sourceDir, joinHdr, fileHdl);
                fclose (fileHdl);

                // Rename file as a temporary file
                sprintf (tempName, "%s%s", sourceDir, ".CAT");

                rename (destName, tempName);

                String strDir(sourceDir);
                size_t pos = strDir.find_last_of ( '\\' );
                if ( String::npos == pos )
                    pos = strDir.find_last_of ( '/' );
                String strFolderName = strDir.substr ( pos + 1 );
                String strParentDir = strDir.substr(0, pos);

                // Compress the file @2
                if ( ( nErr = file_compress ( strParentDir.c_str(), strFolderName.c_str(), ".CAT", extName, outmode ) ) != 0 )
                {                    
                    free(joinHdr);
                    String msg = String("Failed to compress ") + tempName;
                    throw std::exception ( msg.c_str() );
                    return nErr;
                }
            }
        }
        free(joinHdr);
        joinHdr = NULL;
    }
    else
        throw std::exception("Insufficient memory");

    // For debugging only
    #ifdef DEBUG_MODE
    printHeader (stdout,joinHdr);
    #endif

    return errno;
}
void T3kSoftlogicDlg::on_BtnNew_clicked()
{
    if( isModified() )
    {
        QMessageBox msg( QMessageBox::Question, "Warning", "Would you like to save this data?", QMessageBox::Yes|QMessageBox::No, this );
        if( msg.exec() == QMessageBox::Yes )
        {
            m_pTabPanelWidget->updateDataFromUI();

            QString strPanelName = T3kCommonData::instance()->getKeys().getPanelName();
            if( strPanelName.isEmpty() )
            {
                QMessageBox msg( QMessageBox::Critical, "Error", "Panel Name is required.", QMessageBox::Ok, this );
                msg.exec();
                setFocusPanelName();
                return;
            }

            QString strModelName( m_strLoadedModelPathName.right( m_strLoadedModelPathName.length() - m_strLoadedModelPathName.lastIndexOf('/') - 1 ) );
            int nIdx = strModelName.indexOf( '.' );
            strModelName = strModelName.left( nIdx );

            if( m_strLoadedModelPathName.isEmpty() || strModelName != strPanelName )
            {
                QString strFileName = strPanelName;
                strFileName += ".hsk";

                QString strDir( QApplication::applicationDirPath() );
                if( !m_strLoadedModelPathName.isEmpty() )
                {
                    int nBP = m_strLoadedModelPathName.lastIndexOf( '/' );
                    strDir = m_strLoadedModelPathName.left( nBP+1 );
                }

                QString strSave = QFileDialog::getSaveFileName( this, "Save", strDir, "Files(*.hsk)", &strFileName );
                if( strSave.isEmpty() )
                    return;

                m_strLoadedModelPathName = strSave;
            }

            saveModel( m_strLoadedModelPathName );

            T3kCommonData::instance()->resetCalibrationData();

            //m_wndTab.ResetNotify();
        }
    }

    T3kCommonData::KeyDataMode eMode = T3kCommonData::instance()->getKeyDataMode();
    T3kCommonData::instance()->setKeyDataMode( T3kCommonData::KeyDataModeNormal );

    CSoftkeyArray& Keys = T3kCommonData::instance()->getKeys();
    Keys.clear();
    T3kCommonData::instance()->getLogics().clear();

    Keys.resetPanelInfo();

    Keys.setModified( false );

    m_strLoadedModelPathName.clear();

    m_pTabPanelWidget->updateUIFromData();
    m_pTabKeyDesignWidget->refresh();

    T3kCommonData::instance()->setKeyDataMode( eMode );

    T3kCommonData::instance()->resetCalibrationData();

    onUpdatePrewview();
}
示例#18
0
// Load config info
bool ecSettings::LoadConfig()
{
    wxConfig config(wxGetApp().GetSettings().GetConfigAppName());
    
    config.Read(_("/Window Status/FrameStatus"), & m_frameStatus);
    config.Read(_("/Window Status/ShowToolBar"), (bool*) & m_showToolBar);
    config.Read(_("/Window Status/ShowSplashScreen"), (bool*) & m_showSplashScreen);
    config.Read(_("/Window Status/ShowConflictsWindow"), (bool*) & m_showConflictsWindow);
    config.Read(_("/Window Status/ShowPropertiesWindow"), (bool*) & m_showPropertiesWindow);
    config.Read(_("/Window Status/ShowShortDescrWindow"), (bool*) & m_showShortDescrWindow);
    config.Read(_("/Window Status/ShowMemoryWindow"), (bool*) & m_showMemoryWindow);
    config.Read(_("/Window Status/ShowOutputWindow"), (bool*) & m_showOutputWindow);
    
    config.Read(_("/Files/LastFile"), & m_lastFilename);
    
    config.Read(_("/Window Size/WindowX"), & m_frameSize.x);
    config.Read(_("/Window Size/WindowY"), & m_frameSize.y);
    config.Read(_("/Window Size/WindowWidth"), & m_frameSize.width);
    config.Read(_("/Window Size/WindowHeight"), & m_frameSize.height);

    config.Read(_("/Window Size/TreeSashWidth"), & m_treeSashSize.x);
    config.Read(_("/Window Size/TreeSashHeight"), & m_treeSashSize.y);
    config.Read(_("/Window Size/ConfigPaneWidth"), & m_configPaneWidth);
    config.Read(_("/Window Size/ConflictsWidth"), & m_conflictsSashSize.x);
    config.Read(_("/Window Size/ConflictsHeight"), & m_conflictsSashSize.y);
    config.Read(_("/Window Size/PropertiesWidth"), & m_propertiesSashSize.x);
    config.Read(_("/Window Size/PropertiesHeight"), & m_propertiesSashSize.y);
    config.Read(_("/Window Size/ShortDescrWidth"), & m_shortDescrSashSize.x);
    config.Read(_("/Window Size/ShortDescrHeight"), & m_shortDescrSashSize.y);
    config.Read(_("/Window Size/OutputWidth"), & m_outputSashSize.x);
    config.Read(_("/Window Size/OutputHeight"), & m_outputSashSize.y);
    config.Read(_("/Window Size/MemoryWidth"), & m_memorySashSize.x);
    config.Read(_("/Window Size/MemoryHeight"), & m_memorySashSize.y);

    config.Read(_("/Options/ShowMacroNames"), (bool*) & m_showMacroNames);
    config.Read(_("/Options/UseCustomViewer"), (bool*) & m_bUseCustomViewer);
    config.Read(_("/Options/UseExternalBrowser"), (bool*) & m_bUseExternalBrowser);
    
    int tmp = (int) m_eUseCustomBrowser;
    config.Read(_("/Options/UseCustomBrowser"), & tmp);
    m_eUseCustomBrowser = (ecBrowserType) tmp;
    
    config.Read(_("/Options/Browser"), & m_strBrowser);
    config.Read(_("/Options/Viewer"), & m_strViewer);
    config.Read(_("/Options/HexDisplay"), (bool*) & m_bHex);
    config.Read(_("/Options/UseDefaultFonts"), (bool*) & m_windowSettings.m_useDefaults);
    config.Read(_("/Rule/Checking"), & m_nRuleChecking);

    // Find dialog settings
    config.Read(_("/Find/Text"), & m_findText);
    config.Read(_("/Find/MatchWholeWord"), (bool*) & m_findMatchWholeWord);
    config.Read(_("/Find/MatchCase"), & m_findMatchCase);
    config.Read(_("/Find/Direction"), (bool*) & m_findDirection);
    config.Read(_("/Find/SearchWhat"), & m_findSearchWhat);
    config.Read(_("/Find/DialogX"), & m_findDialogPos.x);
    config.Read(_("/Find/DialogY"), & m_findDialogPos.y);

    // Package dialog settings
    config.Read(_("/Packages/OmitHardwarePackages"), & m_omitHardwarePackages);
    config.Read(_("/Packages/MatchPackageNamesExactly"), & m_matchPackageNamesExactly);

    // Run tests settings
    m_runTestsSettings.LoadConfig(config);

    // Fonts
    m_windowSettings.LoadConfig(config);   
    
    if (!config.Read(_("/Paths/UserToolsDir"), & m_userToolsDir))
    {
        // Use the default provided by the installer
        config.Read(_("Default User Tools Path"), & m_userToolsDir);
    }

    // Only to be used if we fail to find the information installed
    // with the Configuration Tool.
    config.Read(_("/Paths/BuildToolsDir"), & m_buildToolsDir);
    if (m_buildToolsDir.IsEmpty()) // first invocation by this user
    {
        // we have no clues as to the location of the build tools so
        // test for ../../../gnutools relative to the configtool location
        wxFileName gnutools = wxFileName (wxGetApp().GetAppDir(), wxEmptyString);
        gnutools.Normalize(); // remove trailing "./" if present
		if (2 < gnutools.GetDirCount())
        {
            gnutools.RemoveDir (gnutools.GetDirCount()-1);
            gnutools.RemoveDir (gnutools.GetDirCount()-1);
            gnutools.RemoveDir (gnutools.GetDirCount()-1);
            gnutools.AppendDir (wxT("gnutools"));
            if (gnutools.DirExists()) // we've found the gnutools
                m_buildToolsDir = gnutools.GetFullPath();
        }
    }

    // look for *objcopy in and under the build tools directory
    if (! m_buildToolsDir.IsEmpty())
    {
        wxArrayString objcopyFiles;
        wxString objcopyFileSpec(wxT("objcopy"));
#ifdef __WXMSW__
        objcopyFileSpec += wxT(".exe");
#endif
        size_t objcopyCount = wxDir::GetAllFiles(m_buildToolsDir, &objcopyFiles, wxT("*") + objcopyFileSpec, wxDIR_FILES | wxDIR_DIRS);
        for (int count=0; count < objcopyCount; count++)
        {
            wxFileName file (objcopyFiles [count]);
            wxString new_prefix (file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec)));
            if ((! new_prefix.IsEmpty()) && ('-' == new_prefix.Last()))
                new_prefix = new_prefix.Left (new_prefix.Len() - 1); // strip off trailing hyphen
            m_arstrBinDirs.Set(new_prefix, file.GetPath(wxPATH_GET_VOLUME));
        }
    }

    if (!config.Read(_("/Build/Make Options"), & m_strMakeOptions))
    {
#ifdef __WXMSW__
        SYSTEM_INFO SystemInfo;
        GetSystemInfo(&SystemInfo);
//        disable -j option for now due to problem with Cygwin 1.3.18
//        m_strMakeOptions.Printf(_T("-j%d"),SystemInfo.dwNumberOfProcessors);
#endif
    }
    
    // Set default build tools binary directories as specified by the installer
    ecFileName strDefaultBuildToolsPath;

#ifdef __WXMSW__
    {
        // This should look in HKEY_LOCAL_MACHINE

        wxConfig config2(wxT("eCos"), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_LOCAL_FILE);

        wxString versionKey = GetInstallVersionKey();
        wxConfigPathChanger path(& config2, wxString(wxT("/")) + versionKey + wxT("/"));

        if (!versionKey.IsEmpty() && config2.Read(wxT("Default Build Tools Path"), & strDefaultBuildToolsPath))
        {
#ifdef __WXMSW__
            wxString gccExe(wxT("*-gcc.exe"));
#else
            wxString gccExe(wxT("*-gcc"));
#endif
            
            // Note that this is not a recursive search. Compilers for
            // different targets may be in the same directory. This finds all targets.
            
            // look for *-gcc[.exe] in the default build tools directory
            wxLogNull log;
            wxDir finder(strDefaultBuildToolsPath);
            wxString filename;
            
            if (finder.IsOpened())
            {
                bool bMore = finder.GetFirst(& filename, gccExe);
                while (bMore)
                {
                    wxString targetName = filename.Left(filename.Find(wxT("-gcc")));
                    m_arstrBinDirs.Set(targetName, strDefaultBuildToolsPath);
                    
                    bMore = finder.GetNext(& filename);
                }
            }
        }
    }
#endif

#ifndef __WXMSW__
    // Look in the PATH for build tools, under Unix
    {
        wxString strPath;
        if (wxGetEnv(wxT("PATH"), & strPath))
        {
	    wxString gccExe(wxT("*-gcc"));

	    wxArrayString arstrPath;
            ecUtils::Chop(strPath, arstrPath, wxT(':'));

            for (int i = arstrPath.GetCount()-1;i >= 0; --i)
            { // Reverse order is important to treat path correctly
                if (wxT(".") != arstrPath[i] && !arstrPath[i].IsEmpty())
                {
                    wxLogNull log;
                    wxDir finder(arstrPath[i]);
                    wxString filename;

                    if (finder.IsOpened())
                    {
                        bool bMore = finder.GetFirst(& filename, gccExe);
                        while (bMore)
                        {
                            wxString targetName = filename.Left(filename.Find(wxT("-gcc")));
                            m_arstrBinDirs.Set(targetName, arstrPath[i]);

                            bMore = finder.GetNext(& filename);
                        }
                    }
                }
            }
        }
    }
#endif
    
    // Read build tools directories (current user)
    
    {
        wxConfigPathChanger path(& config, wxT("/Build Tools/"));
        //config.SetPath(wxT("/Build Tools"));
        wxString key(wxT(""));
        long index;
        bool bMore = config.GetFirstEntry(key, index);
        while (bMore)
        {
            wxString value;
            if (config.Read(key, & value))
            {
                m_arstrBinDirs.Set(key, value);
            }
            bMore = config.GetNextEntry(key, index);
        }
    }
    
    // Read toolchain paths (local machine again)
#ifdef __WXMSW__    
    wxArrayString arstrToolChainPaths;

    // Use eCos just as a test.
    //GetRepositoryRegistryClues(arstrToolChainPaths,_T("eCos"));
    GetRepositoryRegistryClues(arstrToolChainPaths,_T("GNUPro eCos"));
    
    size_t i;
    for (i = (size_t) 0; i < arstrToolChainPaths.GetCount(); i++)
    {
        ecFileName strDir(arstrToolChainPaths[i]);
        strDir += wxT("H-i686-cygwin32\\bin");
        
        if (strDir.IsDir())
        {
            // This is a potential toolchain location. Look for *-gcc.exe
            wxLogNull log;
            wxDir finder(strDefaultBuildToolsPath);
            wxString filename;
            
            if (finder.IsOpened())
            {
                bool bMore = finder.GetFirst(& filename, wxT("*-gcc.exe"));
                while (bMore)
                {
                    // TODO: if there is more than one path, we will have to
                    // check the existance of this target name in m_arstrBinDirs and
                    // append to the end, or something.
                    wxString targetName = filename.Left(filename.Find(wxT("-gcc")));
                    m_arstrBinDirs.Set(targetName, strDefaultBuildToolsPath);
                    
                    bMore = finder.GetNext(& filename);
                }
            }
        }
    }

    // The official user tools are now Cygwin 00r1. If you can't find these,
    // try GNUPro unsupported.
    GetRepositoryRegistryClues(m_userToolPaths, wxT("GNUPro 00r1"));
    if (m_userToolPaths.GetCount() == 0)
    {
        GetRepositoryRegistryClues(m_userToolPaths, wxT("Cygwin 00r1"));
    }

    if (m_userToolPaths.GetCount() > 0)
    {
        for ( i = (size_t) 0 ; i < m_userToolPaths.GetCount(); i++)
        {
            ecFileName str(m_userToolPaths[i]);
            str += "H-i686-cygwin32\\bin";
            if(str.IsDir())
            {
                m_userToolPaths[i] = str;
            } else
            {
                m_userToolPaths.Remove(i);
                i--;
            }
        }
    }
    else
    {
        GetRepositoryRegistryClues(m_userToolPaths, wxT("GNUPro unsupported"));
        
        for ( i = (size_t) 0 ; i < m_userToolPaths.GetCount(); i++)
        {
            ecFileName str(m_userToolPaths[i]);
            str += "H-i686-cygwin32\\bin";
            if(str.IsDir())
            {
                m_userToolPaths[i] = str;
            } else
            {
                m_userToolPaths.Remove(i);
                i--;
            }
        }
    }
#endif
    
    // Include the path in the set of potential user paths
    {
        wxString strPath;
        if (wxGetEnv(wxT("PATH"), & strPath))
        {
            wxArrayString arstrPath;
            ecUtils::Chop(strPath, arstrPath, wxT(';'));
            
            for (int i = arstrPath.GetCount()-1;i >= 0; --i)
            { // Reverse order is important to treat path correctly

                const ecFileName &strFolder = arstrPath[i];
                if (wxT(".") != strFolder && !strFolder.IsEmpty())
                {
                    ecFileName strFile(strFolder);
                    strFile += wxT("ls.exe");
                    if ( strFile.Exists() )
                    {
                        if (!wxArrayStringIsMember(m_userToolPaths, strFolder))
                        {
                            m_userToolPaths.Add(strFolder);
                        }

                        if ( m_userToolsDir.IsEmpty() )
                        {
                            m_userToolsDir = strFolder;
                        }
                    }
                }
            }
        }
    }
    
    // Load current repository from eCos Configuration Tool/Paths/RepositoryDir
    {
        wxConfig eCosConfig(wxGetApp().GetSettings().GetConfigAppName(), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_LOCAL_FILE);
        wxConfigPathChanger path(& config, wxT("/Repository/"));

        //if (!eCosConfig.Read(wxT("Folder"), & m_strRepository))
        if (!eCosConfig.Read(wxT("/Paths/RepositoryDir"), & m_strRepository))
        {
#ifdef __WXMSW__
            // If we can't find the current folder, look for clues in the registry.
            wxArrayString arstr;
            switch (GetRepositoryRegistryClues(arstr, wxT("eCos")))
            {
            case 0:
                break;
            case 1:
            default:
                m_strRepository = arstr[0];
                break;
            }
#elif defined(__WXGTK__)
            // If we can't find the current folder, look for the latest version
            // in /opt/ecos
            m_strRepository = FindLatestVersion();
#else
            // Unsupported platform
            m_strRepositor = wxEmptyString;
#endif
        }

        // If we have set ECOS_REPOSITORY, this overrides whatever we have
        // read or found.
        wxString envVarValue = wxGetenv(wxT("ECOS_REPOSITORY"));
        if (!envVarValue.IsEmpty())
        {
            // Note that ECOS_REPOSITORY has the packages (or ecc) folder in the name.
            // In order to be in the form that is compatible with configtool operation,
            // it needs to have that stripped off.
            envVarValue = ecUtils::PosixToNativePath(envVarValue); // accommodate posix-style ECOS_REPOSITORY value under Cygwin
            wxString packagesName = wxFileNameFromPath(envVarValue);
            if (packagesName == wxT("ecc") || packagesName == wxT("packages"))
                envVarValue = wxPathOnly(envVarValue);

            m_strRepository = envVarValue;
        }
    }

#ifdef __WXMSW__
    if (m_userToolsDir.IsEmpty())
        m_userToolsDir = GetCygwinInstallPath() + wxT("\\bin");
#else
    if (m_userToolsDir.IsEmpty())
        m_userToolsDir = wxT("/bin");
#endif
    
    return TRUE;
}
示例#19
0
HX_RESULT
CBaseArchiver2::CreateDirectoryList()
{
    UINT32 ulCurrDir = 0;
    const char* pStart = (const char*)m_ArchiveDir;
    const char* pCurr = pStart;
    ULONG32 ulProtocolLen = m_ProtocolName.GetLength();

    if (ulProtocolLen > 0)
    {
	ulProtocolLen += 3; // For :// in <protocol>://<file name path>
    }

    m_ulDirsNeeded = 0;
    m_ulDirsCreated = 0;

    // Skip the first slash
    if (*pCurr == '/')
    {
	pCurr++;
    }

    // Figure out how many directories we will need
    while (*pCurr)
    {
	if (*pCurr == '/')
	{
	    m_ulDirsNeeded++;
	}
	pCurr++;
    }

    if (m_ulDirsNeeded)
    {
	// Create an array large enough to hold them
	HX_ASSERT(!m_ppDirectoryList);
	m_ppDirectoryList = new char*[m_ulDirsNeeded];
	memset(m_ppDirectoryList, 0, m_ulDirsNeeded);

	// Prepare for our second pass
	pCurr = pStart;

	// Skip the first slash
	if (*pCurr == '/')
	{
	    pCurr++;
	}

	// Each time we encounter a slash, add that directory
	// to our list of directories that need to be created
	while (*pCurr)
	{
	    if (*pCurr == '/')
	    {
	    
		// Add this directory to the list
		CHXString strDir(pStart, pCurr - pStart + 1);
		CHXString strDirUrl;
		ConvertFilepathToURL(m_ProtocolName, strDir, strDirUrl);
			
		m_ppDirectoryList[ulCurrDir] = new char[strDirUrl.GetLength() + 1];
		strcpy(m_ppDirectoryList[ulCurrDir], strDirUrl); /* Flawfinder: ignore */
		
		ulCurrDir++;
	
	    }
	    pCurr++;
	}
    }

    return HXR_OK;
}
HRESULT CTsTeleportShellExt::TeleportDirectory(__in_z LPTSTR szFile)
{
    HRESULT hr = S_OK;
    HANDLE hSearch = INVALID_HANDLE_VALUE;
    BOOL bFirst = TRUE;

    BOOL bRet;
    DWORD gle;

    try
    {
        TString strDir(szFile);
        strDir.append(TEXT("\\*"));
        
        do
        {
            WIN32_FIND_DATA fd;

            if (bFirst)
            {
                hSearch = FindFirstFile(strDir.c_str(),
                    &fd);

                bFirst = FALSE;
                bRet = (INVALID_HANDLE_VALUE != hSearch);
            }
            else
            {
                bRet = FindNextFile(hSearch, &fd);
            }
                
            if (!bRet)
            {
                gle = GetLastError();

                if (ERROR_NO_MORE_FILES != gle)
                {
                    hr = HRESULT_FROM_WIN32(gle);
                }                
            }
            LEAVE_IF_FAILED("FindXxxFile (%s) failed", szFile);

            if (bRet)
            {
                //
                // Skip . and .. but send everything else
                //

                if (_tcsncmp(fd.cFileName, TEXT("."), sizeof(".")) &&
                    _tcsncmp(fd.cFileName, TEXT(".."), sizeof("..")))
                {
                    TString strPath(szFile);

                    strPath.append(TEXT("\\")).append(fd.cFileName);
                    
                    hr = TeleportFile((LPTSTR) strPath.c_str()); // recuresion
                    LEAVE_IF_FAILED("TeleportFile (%s) failed", strPath.c_str());
                }
            }
        } while (bRet);
    }
    catch (std::bad_alloc&)
    {
        hr = E_OUTOFMEMORY;
    }
    catch (std::exception&)
    {
        hr = E_UNEXPECTED;
    }

_Function_Exit:

    //
    // Cleanup
    //

    if (INVALID_HANDLE_VALUE != hSearch)
    {
        FindClose(hSearch);
    }

    return hr;
}
示例#21
0
CPlugin::EDoMenu CPlugin::MenuForPanelOrCmdLine(LPWSTR szCmdLine/*=NULL*/
                      , EAutoItem enAutoItem/*=AI_NONE*/)
{
  EDoMenu enRet=DOMNU_ERR_SHOW;
  LPCWSTR* pParams=NULL;
  LPCWSTR* pFiles=NULL;
  LPCWSTR szCommand=NULL;
  auto_sz strCommand;
  do
  {
    unsigned nFiles=0, nFolders=0;
    auto_sz strCurDir;
    bool bGetFromPanel=true;
    if (szCmdLine && GetFilesFromParams(szCmdLine, &pParams, &nFiles, &nFolders, &strCurDir, enAutoItem!=AI_NONE))
    {
      assert(pParams);
      pFiles=pParams;
      if (enAutoItem==AI_NONE)
      {
        bGetFromPanel=false;
      }
      else
      {
        strCommand=pParams[0];
        szCommand=strCommand;
        pFiles=pParams+1;
        if (nFiles+nFolders>0)
        {
          bGetFromPanel=false;
        }
        else
        {
          delete[] pParams;
          pParams=NULL;
        }
      }
    }
    if (bGetFromPanel)
    {
      if (!GetFilesFromPanel(&pParams, &nFiles, &nFolders, &strCurDir))
      {
        break;
      }
      assert(pParams);
      assert(nFiles+nFolders);
      pFiles=pParams;
    }
    auto_sz strFilesDir;
    bool bMenuAssigned=false;
    bool bDifferentFolders=false;
    unsigned i;
    for (i=0; i<nFiles+nFolders; i++)
    {
      LPCWSTR szFName=m_fsf.PointToName(pFiles[i]);
      if (pFiles[i]==szFName)
      {
        if (!bMenuAssigned)
        {
          strFilesDir=strCurDir;
          bMenuAssigned=true;
        }
        else if (strFilesDir!=strCurDir)
        {
          bDifferentFolders=true;
          break;
        }
      }
      else
      {
        if (*szFName==L'\0')
        {
          // это бывает для дисков (c:, c:\)
          szFName=pFiles[i];
        }
        auto_sz strDir(pFiles[i], szFName-pFiles[i]);
        if (!bMenuAssigned)
        {
          strFilesDir=strDir;
          bMenuAssigned=true;
        }
        else if (strFilesDir!=strDir)
        {
          bDifferentFolders=true;
          break;
        }
        pFiles[i]=szFName;
      }
    }
    if (bDifferentFolders)
    {
      enRet=DOMNU_ERR_DIFFERENT_FOLDERS;
      break;
    }
    CPidl oDirPidl(m_pMalloc);
    ULONG nCount;
    if (FAILED(m_pDesktop->ParseDisplayName(NULL_HWND, NULL, strFilesDir, &nCount, &oDirPidl, NULL)))
    {
      enRet=DOMNU_ERR_SHOW;
      break;
    }
    IShellFolderPtr pCurFolder;
    if (FAILED(m_pDesktop->BindToObject(oDirPidl, NULL, IID_IShellFolder, reinterpret_cast<void**>(&pCurFolder))))
    {
      enRet=DOMNU_ERR_SHOW;
      break;
    }
    CPidl oPidl(m_pMalloc);
    for (i=0; i<nFiles+nFolders; i++)
    {
      LPITEMIDLIST pidl;
      auto_sz szFile(pFiles[i]);
      if (szFile.Len()==2 && L':'==szFile[1])
      {
        // диск (c:)
        szFile+=L"\\";
      }
      HRESULT hr=0;
      if (FAILED(hr=pCurFolder->ParseDisplayName(NULL_HWND, NULL, szFile, &nCount, &pidl, NULL)))
      {
        enRet=DOMNU_ERR_SHOW;
        break;
      }
      oPidl.Add(pidl);
    }
    if (oPidl.Count()==nFolders+nFiles)
    {
      enRet=DoMenu(pCurFolder, oPidl.GetArray(), pFiles, nFiles, nFolders, szCommand, enAutoItem);
    }
  } while (0);
  delete[] pParams;
  return enRet;
}