Esempio n. 1
0
static void StartQueuedSounds()
{
	CString *p;
	while( g_SoundsToPlayOnce.read( &p, 1 ) )
	{
		if( *p != "" )
			SOUNDMAN->PlayOnce( *p );
		delete p;
	}

	while( g_SoundsToPlayOnceFromDir.read( &p, 1 ) )
	{
		CString sPath( *p );
		DoPlayOnceFromDir( sPath );
		delete p;
	}

	while( g_SoundsToPlayOnceFromAnnouncer.read( &p, 1 ) )
	{
		CString sPath( *p );
		if( sPath != "" )
			sPath = ANNOUNCER->GetPathTo( sPath );
		DoPlayOnceFromDir( sPath );
		delete p;
	}

	MusicToPlay *pMusic;
	while( g_MusicsToPlay.read( &pMusic, 1 ) )
	{
		/* Don't bother starting this music if there's another one in the queue after it. */
		/* Actually, it's a little trickier: the editor gives us a stop and then a sound in
		 * quick succession; if we ignore the stop, we won't rewind the sound if it was
		 * already playing.  We don't want to waste time loading a sound if it's going
		 * to be replaced immediately, though.  So, if we have more music in the queue,
		 * then forcibly stop the current sound. */
		if( !g_MusicsToPlay.num_readable() )
			StartMusic( *pMusic );
		else
		{
			CHECKPOINT;
			/* StopPlaying() can take a while, so don't hold the lock while we stop the sound. */
			g_Mutex->Lock();
			RageSound *pOldSound = g_Playing->m_Music;
			g_Playing->m_Music = new RageSound;
			g_Mutex->Unlock();

			SOUNDMAN->DeleteSound( pOldSound );
		}
		delete pMusic;
	}
}
Esempio n. 2
0
FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
	FILE_ITEM item;
	item.handle = handle;
	item.bCached = false;

	if (filesTree.empty()) {
		item.path = new char[strlen(absolutePath) + 1];
		strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
		item.nPathLen = strlen(item.path);

		filesTree.set_head(item);
		topNode = filesTree.begin();
	}
	else {
		std::string sPath(absolutePath);
		tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
		std::string splittedPath = sPath.substr(sPath.find_last_of('\\') + 1);
		item.path = new char[splittedPath.length() + 1];
		strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
		if (parentNode) {
			filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
		} else {
			//printf("Parent node found for %s", absolutePath);
		}
	}

	DisplayTree(topNode.node, 0);

	return item;
}
/* OnFileNameChange
 * ----------------------------------------------------------------------------
 */
void CFolderDialog::OnFileNameChange()
{
    TCHAR szPath[MAX_PATH];

    GetCurrentDirectory (MAX_PATH, szPath);
    m_sSelPath = CString(szPath);

    // get the list control
    CWnd *pParent = GetParent()->GetDlgItem(lst2);
    CListCtrl *pList = (CListCtrl *)pParent->GetDlgItem(1);

    // currently selected item
    int pos = pList->GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);

    if (pos != -1)
    {
        // create the full path...
        CString sSel(pList->GetItemText(pos, 0));
        CString sPath(szPath);

        if (m_sSelPath.GetAt(m_sSelPath.GetLength() - 1) == '\\')
        {
            sPath = CString (szPath) + sSel;
        }
        else
        {
            sPath = CString (szPath) + _T ( "\\" ) + sSel;
        }

        if (::IsDirectory(sPath))
            m_sSelPath = sPath;
    }

    SetControlText(edt1, m_sSelPath);
}
Esempio n. 4
0
//deletes the specified key from the registry
BOOL DeleteRegistryKey(HKEY hCurrentKey, const char* pszKeyPath)
{
	CString sPath(pszKeyPath);

	int nSlashPos = sPath.FindOneOf("\\/");

	//see if we are at the end
	if(nSlashPos == -1)
	{
		//we are at the end, delete the value
		RegDeleteKey(hCurrentKey, sPath);
		return TRUE;
	}
	else
	{
		CString sCurrDir = sPath.Left(nSlashPos);
		
		//trim off the path
		sPath = sPath.Mid(nSlashPos + 1);

		//we need to recurse
		HKEY hNewKey;
		if(RegOpenKey(hCurrentKey, sCurrDir, &hNewKey) == ERROR_SUCCESS)
		{
			BOOL bRV = DeleteRegistryKey(hNewKey, sPath);
			RegCloseKey(hNewKey);
			return bRV;
		}
		else
		{
			return TRUE;
		}
	}
}
Esempio n. 5
0
//! Создаёт путь к файлу.
bool CreateFileDir(LPCTSTR pszFilePath)
{
    // Найдём полный путь
    TCHAR szBuffer[1024];
    LPTSTR pszFilePart;
    DWORD dwRes = GetFullPathName(pszFilePath, sizeof(szBuffer)/sizeof(*szBuffer), szBuffer, &pszFilePart);
    if (dwRes == 0
        || dwRes >= sizeof(szBuffer)/sizeof(*szBuffer)
        || pszFilePart == NULL)
        return false;

    // Отрежем имя файла
    *pszFilePart = _T('\0');

    CString sPath(szBuffer);
    sPath.Replace(_T('/'), _T('\\'));
    ASSERT(sPath.Right(1) == _T("\\"));

    int nPos;
    if (sPath.Left(2) == _T("\\\\"))
        nPos = sPath.Find(_T("\\"), sPath.Find(_T("\\"), 2) + 1) + 1; // Пропустим имя компьютера и шары
    else
        nPos = 4; // Пропустим имя диска
    while ( (nPos = sPath.Find(_T('\\'), nPos + 1)) != -1)
    {
        if (!CreateDirectory(sPath.Left(nPos), NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
            return false;
    }
    return true;
}
bool PersonalDictionary::SavePersonalDictionary()
{
  wxFileName sPath(m_strDictionaryFileName);
  sPath.MakeAbsolute();

  wxTextFile DictFile(sPath.GetFullPath());
  
  // Remove any existing personal dictionary files
  if (DictFile.Exists())
    ::wxRemoveFile(sPath.GetFullPath());
  
  if (!DictFile.Create())
  {
    wxMessageOutput* msgOut = wxMessageOutput::Get();
    if (msgOut)
      msgOut->Printf(_T("Unable to open personal dictionary file\n"));
    return false;
  }

  //DictFile.Clear();
  for (unsigned int i=0; i<m_DictionaryWords.GetCount(); i++)
    DictFile.AddLine(m_DictionaryWords[i]);

  DictFile.Write();
  DictFile.Close();
  return true;
}
Esempio n. 7
0
vfs::Path Config::realPath(const std::string &movie) const
{
  std::string rmovie = movie;
  _d->resetIfalias( rmovie );

  vfs::Path sPath( rmovie );
  vfs::Path realPath;

  if( realPath.extension().empty() )
  {
    for( auto& dir : _d->folders )
    {
      for( auto& ext : _d->extensions )
      {
        realPath = sPath.changeExtension( ext );
        realPath = dir.find( realPath.baseName(), vfs::Path::ignoreCase );

        if( !realPath.toString().empty() )
          return realPath;
      }
    }
  }
  else
  {
    for( auto& dir : _d->folders )
    {
      realPath = dir/sPath;

      if( realPath.exist() )
        return realPath;
    }
  }

  return vfs::Path();
}
Esempio n. 8
0
int LoadMap(std::string sMapName)
{
    int i, j;

    std::string sPath("map/");
    std::string sExtension(".map");

    std::ifstream stMap((sPath+sMapName+sExtension).c_str());
    if(!stMap)
    {
        std::cout<<"Erreur LoadMap : Map introuvable"<<std::endl;
        return false;
    }

    if(stMap)
    {
        for(i=0 ; i<WORLD_HEIGHT_CUBE ; i++)
        {
            for(j=0 ; j<WORLD_WIDTH_CUBE ; j++)
            {
                stMap>>nWorld[i][j];
                stMap>>nWorldSpe[i][j];
            }
        }
    }
    return true;
}
Esempio n. 9
0
void CGameListCtrl::BrowseForDirectory()
{
	wxString dirHome;
	wxGetHomeDir(&dirHome);

	// browse
	wxDirDialog dialog(this, _("Browse for a directory to add"), dirHome,
			wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);

	if (dialog.ShowModal() == wxID_OK)
	{
		std::string sPath(dialog.GetPath().mb_str());
		std::vector<std::string>::iterator itResult = std::find(
				SConfig::GetInstance().m_ISOFolder.begin(),
				SConfig::GetInstance().m_ISOFolder.end(), sPath);

		if (itResult == SConfig::GetInstance().m_ISOFolder.end())
		{
			SConfig::GetInstance().m_ISOFolder.push_back(sPath);
			SConfig::GetInstance().SaveSettings();
		}

		Update();
	}
}
Esempio n. 10
0
void CPreferencesDlg::AddPage(CPreferencesPageBase* pPage, UINT nIDPath, UINT nIDSection)
{
	CEnString sPath(nIDPath);
	
	if (FindPage(pPage) != -1) 
	{
		HTREEITEM htiParent = TVI_ROOT; // default
		CString sParent(sPath);
		
		while (Misc::Split(sParent, sPath, PATHDELIM))
		{
			// see if parent already exists
			HTREEITEM htiParentParent = htiParent;
			htiParent = m_tcPages.GetChildItem(htiParentParent);
			
			while (htiParent)
			{
				if (sParent.CompareNoCase(m_tcPages.GetItemText(htiParent)) == 0)
					break;
				
				htiParent = m_tcPages.GetNextItem(htiParent, TVGN_NEXT);
			}
			
			if (!htiParent)
			{
				htiParent = m_tcPages.InsertItem(sParent, htiParentParent);
				
				// embolden root items
				if (htiParentParent == TVI_ROOT)
					m_tcPages.SetItemState(htiParent, TVIS_BOLD, TVIS_BOLD);
			}

			// next
			sParent = sPath;
		}
		
		HTREEITEM hti = m_tcPages.InsertItem(sPath, htiParent); // whatever's left
		m_tcPages.EnsureVisible(hti);
		
		// embolden root items
		if (htiParent == TVI_ROOT)
			m_tcPages.SetItemState(hti, TVIS_BOLD, TVIS_BOLD);
		
		// map both ways
		m_tcPages.SetItemData(hti, (DWORD)pPage);

		// don't remap the page if already done
		HTREEITEM htiMap = NULL;
		
		if (!m_mapPP2HTI.Lookup(pPage, htiMap))
			m_mapPP2HTI[pPage] = hti;

		// map the treeitem to its section if it has one
		if (nIDSection)
			m_mapHTIToSection[hti] = nIDSection;

		// set page background to window back
		pPage->SetBackgroundColor(GetSysColor(COLOR_WINDOW));
	}
}
Esempio n. 11
0
Actor* ActorUtil::MakeActor( const RString &sPath_, Actor *pParentActor )
{
	RString sPath( sPath_ );

	FileType ft = GetFileType( sPath );
	switch( ft )
	{
	case FT_Lua:
		{
			auto_ptr<XNode> pNode( LoadXNodeFromLuaShowErrors(sPath) );
			if( pNode.get() == NULL )
			{
				// XNode will warn about the error
				return new Actor;
			}

			Actor *pRet = ActorUtil::LoadFromNode( pNode.get(), pParentActor );
			return pRet;
		}
	case FT_Directory:
		{
			if( sPath.Right(1) != "/" )
				sPath += '/';
			XNode xml;
			xml.AppendAttr( "Class", "BGAnimation" );
			xml.AppendAttr( "AniDir", sPath );

			return ActorUtil::LoadFromNode( &xml, pParentActor );
		}
	case FT_Bitmap:
	case FT_Movie:
		{
			XNode xml;
			xml.AppendAttr( "Class", "Sprite" );
			xml.AppendAttr( "Texture", sPath );

			return ActorUtil::LoadFromNode( &xml, pParentActor );
		}
	case FT_Model:
		{
			XNode xml;
			xml.AppendAttr( "Class", "Model" );
			xml.AppendAttr( "Meshes", sPath );
			xml.AppendAttr( "Materials", sPath );
			xml.AppendAttr( "Bones", sPath );

			return ActorUtil::LoadFromNode( &xml, pParentActor );
		}
	default:
		{
			LOG->Warn( "File \"%s\" has unknown type, \"%s\".", sPath.c_str(), FileTypeToString(ft).c_str() );

			XNode xml;
			xml.AppendAttr( "Class", "Actor" );
			return ActorUtil::LoadFromNode( &xml, pParentActor );
		}
	}
}
Esempio n. 12
0
//--------------------------------------------------------------------------------
CString COutputConfig::GenerateLogfileName() const
	{
	CString sName(CTime::GetCurrentTime().Format("HL7%Y%b%d.txt"));
	CString sPath(m_pLogFile);
	int i = sPath.ReverseFind('\\');
	if(i == -1)
		return sName;
	sPath.GetBufferSetLength(i + 1);
	sPath.ReleaseBuffer();
	return sPath + sName;
	}
Esempio n. 13
0
// Gets the value in a registry key, or returns the default if it cannot be found
// The current key must be one of the HKEY_CLASSES_ROOT, etc. For the path, it should
// be like "dir\dir\keyname"
CString GetRegistryKey(HKEY hCurrentKey, const char* pszKeyPath, const char* pszDefault)
{
	CString sPath(pszKeyPath);

	int nSlashPos = sPath.FindOneOf("\\/");

	if(nSlashPos == -1)
	{
		//we hit the end, we need to try and read the value
		LONG nSize;
		if(RegQueryValue(hCurrentKey, sPath, NULL, &nSize) == ERROR_SUCCESS)
		{
			//create a buffer
			char* pszBuffer = new char [nSize + 1];

			LONG nNewSize = nSize + 1;
			RegQueryValue(hCurrentKey, sPath, pszBuffer, &nNewSize);

			//make sure to end it
			pszBuffer[nSize] = '\0';

			CString sRV(pszBuffer);
			delete [] pszBuffer;

			return sRV;
		}
		else
		{
			return CString(pszDefault);
		}
	}
	else
	{
		CString sCurrDir = sPath.Left(nSlashPos);
		
		//trim off the path
		sPath = sPath.Mid(nSlashPos + 1);

		//we need to recurse
		HKEY hNewKey;
		if(RegOpenKey(hCurrentKey, sCurrDir, &hNewKey) == ERROR_SUCCESS)
		{
			CString sRV = GetRegistryKey(hNewKey, sPath, pszDefault);
			RegCloseKey(hNewKey);
			return sRV;
		}
		else
		{
			//not there
			return CString(pszDefault);
		}
	}
}
Esempio n. 14
0
tree_node_<FILE_ITEM>* CFileTree::findNodeFromRootWithPath(char *path)
{
	if (topNode.node == NULL){
		return NULL;
	}
	std::string sPath(path);
	if (sPath == std::string(topNode->path)) {
		return topNode.node;
	}
	std::string splittedString = sPath.substr(strlen(topNode->path) + 1);
	return findNodeWithPathFromNode(splittedString, topNode.node);
}
Esempio n. 15
0
void MyFrame::onNewTool( wxCommandEvent& ){
	wxString str;
	dlgCreateTool dlg(this);
	if (dlg.ShowModal() != wxID_OK) return;
	wxString sPath(dlg.getFname());
	wxFileName fnTask(sPath);
	wxBitmap * bmp = new wxBitmap(dlg.getBitmap());

	m_toolBar1->AddTool( strIntConf.ulIDTools + m_toolBar1->GetToolsCount(), fnTask.GetFullName(), *bmp/*dlg.getBitmap()*/, sPath/*description*/);
	m_toolBar1->SetToolClientData(strIntConf.ulIDTools + m_toolBar1->GetToolsCount()-1, new wxVariant(dlg.sImagePath));
	m_toolBar1->Realize();
	if(m_toolBar1->GetToolsCount() == strIntConf.ulMaxTools)  GetMenuBar()->Enable(ID_MENUADDTOOL, false);
} 
Esempio n. 16
0
tree_node_<FILE_ITEM>* CFileTree::findParentNodeFromRootForPath(char *path) {
	std::string sPath(path);
	std::string currentPath = sPath.substr(strlen(topNode->path) + 1);
	size_t position = currentPath.find('\\');
	std::string followingPath("");
	if (position == std::string::npos) {
		return topNode.node;
	}
	else {
		followingPath = currentPath.substr(0, currentPath.find_last_of('\\'));
		return findNodeWithPathFromNode(followingPath, topNode.node);
	}
}
Esempio n. 17
0
tree_node_<FILE_ITEM>* CFileTree::findNodeFromRootWithPath(char *path)
{
	// No topNode - bail out.
	if (topNode.node == NULL){
		return NULL;
	}
	std::string sPath(path);
	std::string nPath(topNode->path);
	// topNode path and requested path are the same? Use the node.
	if (sPath == nPath) {
		return topNode.node;
	}
	// printf("Did not find node for path : %s\n", path);

	// If the topNode path is part of the requested path this is a subpath.
	// Use the node.
	if (sPath.find(nPath) != std::string::npos) {
		// printf("Found %s is part of %s  \n", sPath.c_str(), topNode->path);
		std::string splittedString = sPath.substr(strlen(topNode->path) + 1);
		return findNodeWithPathFromNode(splittedString, topNode.node);
	}
	else {
		// If the current topNode isn't related to the requested path
		// iterate over all _top_ level elements in the tree to look for
		// a matching item and register it as current top node.

		// printf("NOT found %s is NOT part of %s  \n", sPath.c_str(), topNode->path);
		tree<FILE_ITEM>::sibling_iterator it;
		for (it = filesTree.begin(); it != filesTree.end(); it++)
		{
			std::string itPath(it.node->data.path);
			// Current item path matches the requested path - use the item as topNode.
			if (sPath == itPath) {
				// printf("Found parent node %s \n", it.node->data.path);
				topNode = it;
				return it.node;
			}
			else if (sPath.find(itPath) != std::string::npos) {
				// If the item path is part of the requested path this is a subpath.
				// Use the the item as topNode and continue analyzing.
				// printf("Found root node %s \n", it.node->data.path);
				topNode = it;
				std::string splittedString = sPath.substr(itPath.length() + 1);
				return findNodeWithPathFromNode(splittedString, it.node);
			}
		}
	}
	// Nothing found return NULL.
	return NULL;
}
Esempio n. 18
0
	bool FindInPath( const std::string fname, std::string& absname ) {
		char* pPath = getenv("PATH");
		if( ! pPath ) return false;
		std::stringstream sPath(pPath);
		for(std::string pathcur; std::getline(sPath, pathcur, ':'); ) {
			std::string testname = pathcur + '/' + fname;
			std::ifstream fin(testname);
			if( fin ) {
				absname = testname;
				return true;
			}
		}
		return false;
	}
Esempio n. 19
0
void CCdromSelectionWnd::SelectImage()
{
	Framework::Win32::CFileDialog Dialog;

	Dialog.m_OFN.lpstrFilter = DISKIMAGE_FILTER;

	if(Dialog.SummonOpen(m_hWnd) != IDOK)
	{
		return;
	}

	std::string sPath(string_cast<std::string>(Dialog.GetPath()));
	m_sImagePath = sPath.c_str();
}
Esempio n. 20
0
void wxGxDiscConnection::OnObjectAdded(wxGxCatalogEvent& event)
{
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
	if(!pGxObject)
		return;
    wxString sPath(pGxObject->GetPath(), wxConvUTF8);
    wxString sConnPath(GetPath(), wxConvUTF8);
    if(sPath.StartsWith(sConnPath))
    {
        if(!IsPathWatched(sPath) && pGxObject->IsKindOf(wxCLASSINFO(wxGxFolder)))
        {
            wxFileName oFileName = wxFileName::DirName(sPath);
            m_pWatcher->Add(oFileName);
        }
    }
}
Esempio n. 21
0
void MyFrame::onEditTool( wxMenuEvent& ){
	dlgCreateTool dlg(this);
	wxBitmap  bmp(broken_xpm);
	dlg.setFname(m_toolBar1->GetToolShortHelp(idCTool));
	dlg.setBitmap(&bmp);
	if (dlg.ShowModal() != wxID_OK) return;

	wxString sPath(dlg.getFname());
	wxFileName fnTask(sPath);
	int pos = m_toolBar1->GetToolPos(idCTool);
	m_toolBar1->DeleteTool(idCTool);
	m_toolBar1->AddTool( idCTool, fnTask.GetFullName(), dlg.getBitmap(), sPath);
	m_toolBar1->Realize();
	m_toolBar1->InsertTool( pos, m_toolBar1->RemoveTool(idCTool));
	m_toolBar1->Realize();
}
Esempio n. 22
0
static int osc_send_quit ( DssiEditor *pDssiEditor )
{
	if (pDssiEditor->busy > 0)
		return 1;
	if (pDssiEditor->target == NULL)
		return 1;

#ifdef CONFIG_DEBUG
	qDebug("osc_send_quit: path \"%s\"", pDssiEditor->path);
#endif

	QString sPath(pDssiEditor->path);
	sPath += "/quit";
	lo_send(pDssiEditor->target, sPath.toUtf8().constData(), "");

	return 0;
}
   String 
   MySQLInterface::GetLibraryFileName_()
   {
      LPTSTR szPath = (LPTSTR)alloca( 2048 );
      DWORD  dwPathLength;

      dwPathLength = GetModuleFileName(NULL, szPath, 2048 );
      szPath[ dwPathLength ] = 0; // --- nullterminated.

      String sPath(szPath);

      int iLastSlash = max(sPath.ReverseFind(_T("\\")), sPath.ReverseFind(_T("/")));
      String sRetVal = sPath.Mid(0, iLastSlash);
      sRetVal += "\\libmysql.dll";

      return sRetVal;
   }
Esempio n. 24
0
void WnetMgr::getNetFullPath(xpr::string &aFullPath)
{
    aFullPath.clear();

    xpr::string sPath(XPR_STRING_LITERAL("\\\\127.0.0.1"));
    LPITEMIDLIST sFullPidl = fxfile::base::Pidl::create(sPath.c_str());
    if (XPR_IS_NOT_NULL(sFullPidl))
        return;

    GetDispFullPath(sFullPidl, aFullPath);

    xpr_size_t sFind = aFullPath.rfind(XPR_STRING_LITERAL('\\'));
    if (sFind != xpr::string::npos)
        aFullPath.erase(sFind);

    COM_FREE(sFullPidl);
}
Esempio n. 25
0
   String
   Application::GetExecutableName()
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Returns the name of the executable (h*.exe)
   //---------------------------------------------------------------------------()
   {
      LPTSTR szPath = (LPTSTR)alloca( 2048 );
      DWORD  dwPathLength;
   
      HMODULE handle = GetModuleHandle(_T("hmailserver.exe"));
      dwPathLength = GetModuleFileName(handle, szPath, 2048 );
 
      szPath[ dwPathLength ] = 0; // --- nullterminated.
   
      String sPath(szPath);
      return sPath;
   }
// called by CProjectDoc::OnOpenDocument() for each \+Lang field it encounters
// This STATIC method will read the parameters and then try to open the language
// file.
CLangModelsDoc* CLangModelsDoc::loadDocument(LPCTSTR lpszField,  LPCTSTR sProjectPath)
{
	CString sPath(lpszField); // sAbrev,
//	CParseStream stream(lpszField);
//	stream.word(sAbrev, FALSE);	// i'm  thinking the abrev appearing in the project file is not used anymore
//	stream.getQuotedString(sPath);
	//CCarlaLanguage *pLang = new CCarlaLanguage(sAbrev);
	CFileStatus status;
	// is the file there?
	if(!CFile::GetStatus(sPath, status))
	{
	// if not, look in the same directory as this project
		//CString sPossiblePath = getLang()->getFilePath(getLang()->getLanguageDirectory(sProjectPath, FALSE));
		CString sPossiblePath = ::getDirectory(sProjectPath);
		sPossiblePath += getFileName(sPath);
		sPossiblePath += " control files\\";
		sPossiblePath += getFullFileName(sPath);
		// if it's there, switch the path and don't bother the user
		if(CFile::GetStatus(sPossiblePath, status))
			sPath = sPossiblePath;
		else
		{	// ask the user to find it

			if(!theApp.askUserToFindFile(sPath, CLangModelsDoc::getRegFileTypeID()))
			{
				THROWSTRING3("The language file", getFullFileName(sPath), " could not be found.");
			}
		}
	}

	CLangModelsDoc *pLangDoc = (CLangModelsDoc *)theApp.internalOpenDocumentFile(sPath);
	if(!pLangDoc)
	{
		checkForFileError(sPath);
		THROWSTRING3("The language file ", sPath, " could not be opened.");
	}
	else if(!pLangDoc->IsKindOf(RUNTIME_CLASS(CLangModelsDoc)))
	{
		ASSERTX(FALSE); // to do notify user or something
	}

	return pLangDoc;
}
Esempio n. 27
0
FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
	FILE_ITEM item;
	item.handle = handle;
	item.bCached = false;

	// If the tree is empty just add the new path as node on the top level.
	if (filesTree.empty()) {
		item.path = new char[strlen(absolutePath) + 1];
		strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
		item.nPathLen = strlen(item.path);

		filesTree.set_head(item);
		topNode = filesTree.begin();
	}
	else {
		// Check if the requested path belongs to an already registered parent node.
		std::string sPath(absolutePath);
		tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
		std::string splittedPath = _basename_932(sPath);
		//printf("spl %s %s\n", splittedPath.c_str(), absolutePath);
		item.path = new char[splittedPath.length() + 1];
		strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
		// If a parent was found use th parent.
		if (parentNode) {
			//printf("parent %s\n", parentNode->data.path);
			filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
		} else {
			// Node wasn't found - most likely a new root - add it to the top level.
			//printf("No parent node found for %s. Adding new sibbling.", absolutePath);
			item.path = new char[strlen(absolutePath) + 1];
			strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
			item.nPathLen = strlen(item.path);
			
			filesTree.insert(tree<FILE_ITEM>::iterator_base(topNode), item);
			topNode = filesTree.begin();
		}
	}

	DisplayTree(topNode.node, 0);

	return item;
}
BOOL CCarlaLanguage::open(LPCTSTR lpszPathName)
{
	CString sPath(lpszPathName);
	// this isn't needed since the calling methods make sure it is here
	if(!theApp.askUserToFindFileIfNotFound(sPath, CLangModelsDoc::getRegFileTypeID()))
		return FALSE;




	CSimpleProgressBar pb(_T(""));
	pb.SetTextEx(_T("Loading"), getName(), _T(" Lang File..."));

	USES_CONVERSION_U8;
	SFMFile *pFile = new SFMFile(T2CA(sPath), getCommentChar());
	if(!pFile->ensureOpen(_T("Language Document")))
		return FALSE;
	m_mfs.m_sCtrlFilesDirectory = getDirectory(sPath);

	// rename?
	if(::_tcsicmp(m_mfs.m_sCtrlFilesDirectory.Right(14), _T("Control Files\\")))
	{
		int len = m_mfs.m_sCtrlFilesDirectory.GetLength();
		CString sOldDirName = m_mfs.m_sCtrlFilesDirectory.Left(len-1);
		CString sNewDirName = m_mfs.m_sCtrlFilesDirectory.Left(1+len-_tcslen(_T("Files\\"))) + CONTROL_FOLDER_SUFFIX;

		if(-1 == _taccess(sNewDirName, 00))	// directory not found
		{
			CString s;
			s.Format(_T("This version of CarlaStudio uses a new name for the folder that contains control files.\n\nThe folder named %s will now be renamed to %s"),
						(LPCTSTR)sOldDirName, (LPCTSTR)sNewDirName);
			AfxMessageBox(s, MB_ICONINFORMATION   );
			if(0 == _taccess(m_mfs.m_sCtrlFilesDirectory, 00))	// is the dir of the old name there?
			{
				// rename it
				TRY
				{
					CFile::Rename( sOldDirName, sNewDirName );
				}
				CATCH( CFileException, e )
				{
					::checkForFileError(m_mfs.m_sCtrlFilesDirectory);
				}
    bool CCoherentUISystem::InitializeCoherentUI()
    {
        // register listeners
        m_SystemEventsListener.reset( new CCoherentSystemEventListener( this ) );
        m_InputEventsListener.reset( new CCoherentInputEventListener() );

        gEnv->pGameFramework->RegisterListener( this, "CCoherentUISystem", eFLPriority_HUD );
        gEnv->pInput->AddEventListener( m_InputEventsListener.get() );

        std::string sPath( gPluginManager->GetPluginDirectory( PLUGIN_NAME ) );
        sPath += "\\host";
        std::wstring sPathW;
        sPathW.assign( sPath.begin(), sPath.end() );

        Coherent::UI::SystemSettings settings( sPathW.c_str(), false, true, L"coui://cookies.dat", L"cui_cache", L"cui_app_cache", true, false, 9999 );
        m_pUISystem = InitializeUISystem( COHERENT_KEY, settings, m_SystemEventsListener.get(), Coherent::Logging::Debug, nullptr, &m_PakFileHandler );

        return m_pUISystem != NULL;
    }
Esempio n. 30
0
void GepardGLES2::strokePath()
{
    PathData* pathData = _context.path.pathData();
    GepardState& state = _context.currentState();

    GD_LOG3("Path: " << pathData->firstElement());
    if (!pathData || pathData->isEmpty())
        return;

    Float miterLimit = state.miterLimit ? state.miterLimit : 10;

    StrokePathBuilder sPath(state.lineWitdh, miterLimit, state.lineJoinMode, state.lineCapMode);
    sPath.convertStrokeToFill(pathData);

    Color tempColor = state.fillColor;
    state.fillColor = state.strokeColor;
    fillPath(sPath.pathData(), state);
    state.fillColor = tempColor;
}