Exemplo n.º 1
0
static DWORD WINAPI BeginConversion(LPVOID data)
{
	InternalThreadData* threadData = (InternalThreadData*) data;
	HANDLE conversionHandle = threadData->conversionHandle;
	CPath inputPath = threadData->inputPath;
	CPath outputPath = threadData->outputPath;
	bool isUrl = threadData->isUrl;
	ConversionActivityCallback fcn = threadData->activityCallback;
	void* userData = threadData->userData;
	LONGLONG contentLength = threadData->contentLength;
	wstring contentTitle = threadData->contentTitle;
	__int64 contentDuration = threadData->contentDuration;

	if (outputPath.GetExtension().MakeLower() == _T(".dvr-ms"))
		ConvertToDvrms(conversionHandle, CComBSTR(inputPath), CComBSTR(outputPath), isUrl, ActivityCallback, NULL, contentLength, CComBSTR(contentTitle.c_str()), contentDuration);

	if (outputPath.GetExtension().MakeLower() == _T(".wmv"))
		ConvertToWmv(conversionHandle, CComBSTR(inputPath), CComBSTR(outputPath), isUrl, ActivityCallback, NULL, contentLength, CComBSTR(contentTitle.c_str()), contentDuration);

	if (outputPath.GetExtension().MakeLower() == _T(".wtv"))
		ConvertToWtv(conversionHandle, CComBSTR(inputPath), CComBSTR(outputPath), isUrl, ActivityCallback, NULL, contentLength, CComBSTR(contentTitle.c_str()), contentDuration);

	_done = true;
	return 0;
}
Exemplo n.º 2
0
BOOL CSelectLanguageDlg::OnInitDialog()
{
	// Declare variables
	CPath * pPath = CPath::Instance();

	// Call original function
	CDialog::OnInitDialog();

	// Load right bitmap
	m_bmpImage.LoadBitmap(IDB_SELECTLANGUAGE);

	// We have no languages yet
	m_iLanguageCount = 0;

	// Add all languages that are available in the lng folder
	ListLanguages(pPath->GetPathUpdater() + _T("\\lng\\"));

	// Now add all the languages to the combobox
	for (int i = 0; i < m_iLanguageCount; i++)
	{
		// Add language to combobox
		m_cboLanguage.AddString(m_arrLanguages[i].sDescription);
	}

	// Select english
	m_cboLanguage.SelectString(0, _T("English (original)"));

	// Return TRUE unless you want to set focus to a control
	return TRUE;
}
Exemplo n.º 3
0
void ShowMessage(int headerId, int bodyId, int footerId, HRESULT hr)
{
	HWND hwndExcel = FindCurrentExcelWindow();
	try
	{
		CString addInFullPath = AddInFullPath();

		CPath addInFileName = addInFullPath;
		addInFileName.StripPath();

		CString msgTitle;
		msgTitle.FormatMessage(IDS_MSG_TITLE, addInFileName);

		CString header;
		header.LoadString(headerId);
		CString body;
		body.LoadString(bodyId);
		CString footer;
		footer.LoadString(footerId);
		CString hresult = "";
		if (hr != S_OK)
		{
			hresult.FormatMessage(IDS_MSG_HRESULT, hr);
		}

		CString msg;
		msg.FormatMessage(IDS_MSG_TEMPLATE, header, body, footer, hresult, addInFullPath);

		MessageBox(hwndExcel, msg, msgTitle, MB_ICONEXCLAMATION);
	}
	catch (...)
	{
		ShowMessageError(hwndExcel);
	}
}
Exemplo n.º 4
0
    bool BackupTaskState(void) throw()
    {
        CPath path;
        bool bRet = false;

        if (GetIniFile(path))
        {
            CString temp;
            bRet = true;

            // get storage name
            if (GetConfigString(temp, path, _T("storage"), STORAGE_NAME))
            {
                path.RemoveFileSpec();
                path.Append(temp);

                if (path.FileExists())
                {
                    temp = (LPCTSTR)path; // store existing
                    path.RenameExtension(_T(".bak"));
                    bRet = (::MoveFileEx(temp, path, MOVEFILE_REPLACE_EXISTING) != 0);
                } 
            }
        }
        return bRet;
    }
Exemplo n.º 5
0
bool DisplayHelp()
{
	CPath path;
	if (!::GetModuleFileName(NULL, CStrBufA(path, MAX_PATH), MAX_PATH))
		return false;
	path.StripPath();

	CString str;
	str.FormatMessage(
		_T("Checks the security descriptor on a named object.\n")
		_T("\n")
		_T("Usage: %1 [-?] [-at|-no_at] [-file|-regkey|-service|-kernel|-printer] [objectname]*\n")
		_T("  -?        Display this help message\n")
		_T("  -at       Examine the process access token (default)\n")
		_T("  -no_at    Don't examine the process access token\n")
		_T("  -file     objectname is the name of a file to examine (default)\n")
		_T("  -regkey   objectname is the name of a registry key to examine\n")
		_T("  -service  objectname is the name of a service to examine\n")
		_T("  -kernel   objectname is the name of a kernel object to examine\n")
		_T("            these can be semaphores, events, mutexes, waitable timers, and file mappings\n")
		_T("  -printer  objectname is the name of a printer to examine\n")
		_T("  objectname defaults to \\\\.\\A:\n")
		_T("Example: %1 C:\\boot.ini\n")
		_T("\n")
		_T("Note: \\\\.\\A: is not the same as A:\n")
		_T("Checking \\\\.\\A: checks access to the floppy drive,\n")
		_T("Checking A: checks access to the root directory"),
		path);
	Log(str);

	return false;
}
void ActivationContextLoader::LoadDll()
{
    // Get a handle to the DLL module.
 
	CPath dllPath;
	dllPath.Combine(GetModulePath(), WS_ACTIVATIONCONTEXTLOADER_DLL);
	
    m_hinstLib = LoadLibrary(dllPath); 
 
    // If the handle is valid, try to get the function address.
 
    if (m_hinstLib != NULL) 
    { 
		m_funcLAC = (LAC) GetProcAddress(m_hinstLib, WS_ACLOADFUNC); 
													 
		m_funcULAC = (ULAC) GetProcAddress(m_hinstLib, WS_ACUNLOADFUNC);

		m_funcIAAFM = (IAAFM) GetProcAddress(m_hinstLib, WS_ACALREADYACTIVEFUNC);
    } 
	else
	{
		CStdStringA msg;
		msg.Format("LoadLibrary on '%s'failed. Error code: %d.", WS_ACTIVATIONCONTEXTLOADER_DLL_A, GetLastError());
		throw std::exception(msg);
	}
}
Exemplo n.º 7
0
bool CDownloadQueue::IsFileExisting( const CMD4Hash& fileid ) const 
{
	if (CKnownFile* file = theApp->sharedfiles->GetFileByID(fileid)) {
		if (file->IsPartFile()) {
			AddLogLineC(CFormat( _("You are already trying to download the file '%s'") ) % file->GetFileName());
		} else {
			// Check if the file exists, since otherwise the user is forced to 
			// manually reload the shares to download a file again.
			CPath fullpath = file->GetFilePath().JoinPaths(file->GetFileName());
			if (!fullpath.FileExists()) {
				// The file is no longer available, unshare it
				theApp->sharedfiles->RemoveFile(file);
				
				return false;
			}
			
			AddLogLineC(CFormat( _("You already have the file '%s'") ) % file->GetFileName());
		}
		
		return true;
	} else if ((file = GetFileByID(fileid))) {
		AddLogLineC(CFormat( _("You are already trying to download the file %s") ) % file->GetFileName());
		return true;
	}
	
	return false;
}
Exemplo n.º 8
0
LPCTSTR UtilGetTempPath()
{
	static CPath s_tempPath;
	if(_tcslen(s_tempPath)==0){		//初期設定
		//環境変数取得
		std::map<stdString,stdString> envs;
		UtilGetEnvInfo(envs);
		if(!has_key(envs,_T("TMP")) && !has_key(envs,_T("TEMP"))){
			//%TMP%/%TEMP%が存在しなければ自前の一時フォルダを使う(C:\Users\xxx\AppData\Roaming\LhaForge\temp)
			TCHAR szPath[_MAX_PATH+1]={0};
			SHGetFolderPath(NULL,CSIDL_APPDATA|CSIDL_FLAG_CREATE,NULL,SHGFP_TYPE_CURRENT,szPath);
			s_tempPath=szPath;
			s_tempPath.Append(_T("lhaforge\\temp\\"));
			UtilMakeSureDirectoryPathExists(s_tempPath);
		}else{
			//通常のパス
			std::vector<TCHAR> buffer(GetTempPath(0,NULL)+1);
			GetTempPath(buffer.size(),&buffer[0]);
			buffer.back()=_T('\0');
			s_tempPath=&buffer[0];
			s_tempPath.AddBackslash();
		}
	}
	return s_tempPath;
}
Exemplo n.º 9
0
int CPartFileConvert::ScanFolderToAdd(const CPath& folder, bool deletesource)
{
    int count = 0;
    CDirIterator finder(folder);

    CPath file = finder.GetFirstFile(CDirIterator::File, wxT("*.part.met"));
    while (file.IsOk()) {
        ConvertToeMule(folder.JoinPaths(file), deletesource);
        file = finder.GetNextFile();
        count++;
    }
    /* Shareaza
    file = finder.GetFirstFile(CDirIterator::File, wxT("*.sd"));
    while (!file.IsEmpty()) {
    	ConvertToeMule(file, deletesource);
    	file = finder.GetNextFile();
    	count++;
    }
    */

    file = finder.GetFirstFile(CDirIterator::Dir, wxT("*.*"));
    while (file.IsOk()) {
        ScanFolderToAdd(folder.JoinPaths(file), deletesource);

        file = finder.GetNextFile();
    }

    return count;
}
Exemplo n.º 10
0
void ActivationContextLoader::Initialise(const CStdString& sManifest)
{
	if (CGeneral::FileExists(sManifest))
	{
		m_sManifest = sManifest;
	}
	else
	{
		CPath path;
		path.Combine(GetModulePath(), sManifest);
		m_sManifest = path;
	}

	try
	{
		// Don't do anything if we're not at least running on xp
		m_bShouldLoadActivationContext = ShouldLoadActivationContext();
		if (m_bShouldLoadActivationContext)
		{
			LoadDll();

			if (!IsActivationContextAlreadyActiveForManifest())
			{
				LoadAC();
			}
		}

	}
	catch (std::exception & e)
	{
		CStdString sError = CA2T(e.what());
		LOG_WS_ERROR(sError); 
	}
}
Exemplo n.º 11
0
static CString GetFileName(CString str)
{
	CPath p = str;
	p.StripPath();

	return (LPCTSTR)p;
}
Exemplo n.º 12
0
/**
 *  \brief
 */
bool Settings::Save() const
{
    CPath cfgFile;
    INpp::Get().GetPluginsConfDir(cfgFile);
    cfgFile += cPluginCfgFileName;

    FILE* fp;
    _tfopen_s(&fp, cfgFile.C_str(), _T("wt"));
    if (fp == NULL)
        return false;

    bool success = false;
    if (_ftprintf_s(fp, _T("%s\n"), cInfo) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cUseDefDbKey, (_useDefDb ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cDefDbPathKey, _defDbPath.C_str()) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n"), cREOptionKey, (_re ? _T("yes") : _T("no"))) > 0)
    if (_ftprintf_s(fp, _T("%s%s\n\n"), cICOptionKey, (_ic ? _T("yes") : _T("no"))) > 0)
    if (_genericDbCfg.Write(fp))
        success = true;

    fclose(fp);

    if (success)
        _dirty = false;

    return success;
}
Exemplo n.º 13
0
void CFriendList::LoadList()
{
  	CPath metfile = CPath(theApp->ConfigDir + wxT("emfriends.met"));
	
	if (!metfile.FileExists()) {
		return;
	}
	
	CFile file;
	try {
		if ( file.Open(metfile) ) {
			if ( file.ReadUInt8() /*header*/ == MET_HEADER ) {
				uint32 nRecordsNumber = file.ReadUInt32();
				for (uint32 i = 0; i < nRecordsNumber; i++) {
					CFriend* Record = new CFriend();
					Record->LoadFromFile(&file);
					m_FriendList.push_back(Record);
					Notify_ChatUpdateFriend(Record);
				}				
			}
		} else {
			AddLogLineN(_("Failed to open friend list file 'emfriends.met' for reading!"));
		}
	} catch (const CInvalidPacket& e) {
		AddDebugLogLineC(logGeneral, wxT("Invalid entry in friend list, file may be corrupt: ") + e.what());
	} catch (const CSafeIOException& e) {
		AddDebugLogLineC(logGeneral, wxT("IO error while reading 'emfriends.met': ") + e.what());
	}
	
}
Exemplo n.º 14
0
//設定から出力先フォルダを読み込む
//r_bUseForAll:今後も同じフォルダ設定を使うならtrue
HRESULT GetOutputDirPathFromConfig(OUTPUT_TO outputDirType,LPCTSTR lpszOrgFile,LPCTSTR lpszSpecific,CPath &r_pathOutputDir,bool &r_bUseForAll,CString &strErr)
{
	TCHAR szBuffer[_MAX_PATH+1];
	FILL_ZERO(szBuffer);

	switch(outputDirType){
	case OUTPUT_TO_SPECIFIC_DIR:	//Specific Directory
		//TRACE(_T("Specific Dir:%s\n"),Config.Common.Extract.OutputDir);
		r_pathOutputDir=lpszSpecific;
		if(_tcslen(r_pathOutputDir)>0){
			return S_OK;
		}else{
			//出力先がかかれていなければ、デスクトップに出力する
		}
		//FALLTHROUGH
	case OUTPUT_TO_DESKTOP:	//Desktop
		if(SHGetSpecialFolderPath(NULL,szBuffer,CSIDL_DESKTOPDIRECTORY,FALSE)){
			r_pathOutputDir=szBuffer;
		}else{	//デスクトップがない?
			strErr=CString(MAKEINTRESOURCE(IDS_ERROR_GET_DESKTOP));
			return E_FAIL;
		}
		return S_OK;
	case OUTPUT_TO_SAME_DIR:	//Same Directory
		_tcsncpy_s(szBuffer,lpszOrgFile,_MAX_PATH);
		PathRemoveFileSpec(szBuffer);
		r_pathOutputDir=szBuffer;
		return S_OK;
	case OUTPUT_TO_ALWAYS_ASK_WHERE:	//出力先を毎回聞く
		TRACE(_T("Always ask\n"));
		{
			//元のファイルと同じ場所にする;2回目以降は前回出力場所を使用する
			static CString s_strLastOutput;
			CPath pathTmp;
			if(s_strLastOutput.IsEmpty()){
				pathTmp=lpszOrgFile;
				pathTmp.RemoveFileSpec();
			}else{
				pathTmp=(LPCTSTR)s_strLastOutput;
			}

			CString title(MAKEINTRESOURCE(IDS_INPUT_TARGET_FOLDER_WITH_SHIFT));
			CLFFolderDialog dlg(NULL,title,BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE);
			dlg.SetInitialFolder(pathTmp);
			if(IDOK==dlg.DoModal()){
				r_bUseForAll=(GetKeyState(VK_SHIFT)<0);	//TODO
				r_pathOutputDir=dlg.GetFolderPath();
				s_strLastOutput=(LPCTSTR)r_pathOutputDir;
				return S_OK;
			}else{
				return E_ABORT;	//キャンセルされた
			}
		}
		break;
	default:
		ASSERT(!"This code cannot be run");
		return E_NOTIMPL;
	}
}
Exemplo n.º 15
0
	virtual void setUp()
	{
		const CPath path = CPath(wxT("testfile.txt"));
		if (path.FileExists()) {
			ASSERT_TRUE(CPath::RemoveFile(path));
		}

	}
Exemplo n.º 16
0
TEST(CPath, Cleanup)
{
	const CPath initial = CPath(wxT(" /a\"b*c* <d>?e|\\:f "));

	ASSERT_EQUALS(initial.Cleanup(false, false), Norm(wxT("\%20a\"b*c*\%20<d>?e|\\:f\%20")));
	ASSERT_EQUALS(initial.Cleanup(false, true), Norm(wxT("\%20abc\%20def\%20")));
	ASSERT_EQUALS(initial.Cleanup(true, false), Norm(wxT(" a\"b*c* <d>?e|\\:f ")));
	ASSERT_EQUALS(initial.Cleanup(true, true), Norm(wxT(" abc def ")));
}
Exemplo n.º 17
0
 CString ToRelative(LPCTSTR dir, const LPCTSTR path, bool* pbRelative/* = nullptr*/)
 {
     CPath cp;
     BOOL rel = cp.RelativePathTo(dir, FILE_ATTRIBUTE_DIRECTORY, path, 0);
     if (pbRelative) {
         *pbRelative = !!rel;
     }
     return cp;
 }
Exemplo n.º 18
0
CString CPPageWebServer::GetCurWebRoot()
{
	CString WebRoot;
	GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
	WebRoot.Replace('/', '\\');

	CPath path;
	path.Combine(GetMPCDir(), WebRoot);
	return path.IsDirectory() ? (LPCTSTR)path : _T("");
}
Exemplo n.º 19
0
CFile::CFile(string szFileName)
{
	CPath cPath;
	if(cPath.IsFile(szFileName))
	{
		m_file.open(szFileName.c_str());

	}
	m_name = szFileName;
}
Exemplo n.º 20
0
void CPPageWebServer::OnBnClickedButton1()
{
	CString dir = GetCurWebRoot();
	if(PickDir(dir)) {
		CPath path;
		if(path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
			dir = (LPCTSTR)path;
		}
		m_WebRoot = dir;
		UpdateData(FALSE);
	}
}
Exemplo n.º 21
0
TEST(CPath, CopyConstructor)
{
	const wxChar* tmpPath = wxT("foobar.tgz");

	{
		CPath a(tmpPath);

		ASSERT_TRUE(a.IsOk());
		ASSERT_EQUALS(a.GetRaw(), tmpPath);
		ASSERT_EQUALS(a.GetPrintable(), tmpPath);
		ASSERT_EQUALS(a.GetPath(), CPath());
		ASSERT_EQUALS(a.GetFullName(), CPath(tmpPath));

		CPath b(a);
		ASSERT_TRUE(b.IsOk());
		ASSERT_EQUALS(b.GetRaw(), tmpPath);
		ASSERT_EQUALS(b.GetPrintable(), tmpPath);
		ASSERT_EQUALS(b.GetPath(), CPath());
		ASSERT_EQUALS(b.GetFullName(), CPath(tmpPath));

		ASSERT_EQUALS(a, b);
	}

	{
		CPath a(tmpPath);

		ASSERT_TRUE(a.IsOk());
		ASSERT_EQUALS(a.GetRaw(), tmpPath);
		ASSERT_EQUALS(a.GetPrintable(), tmpPath);
		ASSERT_EQUALS(a.GetPath(), CPath());
		ASSERT_EQUALS(a.GetFullName(), CPath(tmpPath));

		CPath b(a);
		ASSERT_TRUE(b.IsOk());
		ASSERT_EQUALS(b.GetRaw(), tmpPath);
		ASSERT_EQUALS(b.GetPrintable(), tmpPath);
		ASSERT_EQUALS(b.GetPath(), CPath());
		ASSERT_EQUALS(b.GetFullName(), CPath(tmpPath));

		ASSERT_EQUALS(a, b);
	}

	{
		CPath a;
		CPath b(a);
		
		ASSERT_EQUALS(a, b);
		ASSERT_FALSE(a.IsOk());
		ASSERT_FALSE(b.IsOk());
	}
}
Exemplo n.º 22
0
	void CLogic::update_connection_path_on_move( CServer &server, const CNodeEndpoint &connection_path, const CPath &previous_path, const CPath &new_path )
	{
		int previous_path_length;
		int absolute_path_length;
		int characters_after_old_path;

		const CNode *parent = CNode::downcast( connection_path.get_node().get_parent() );
		const string &connection_path_string = *connection_path.get_value();

		ostringstream absolute_path_stream;
		if( parent )
		{
			absolute_path_stream << parent->get_path().get_string() << ".";
		}
	
		absolute_path_stream << connection_path_string;

		const string &absolute_path = absolute_path_stream.str();

		previous_path_length = previous_path.get_string().length();
		absolute_path_length = absolute_path.length();
		if( previous_path_length > absolute_path_length || previous_path.get_string() != absolute_path.substr( 0, previous_path_length ) )
		{
			/* connection_path isn't affected by this move */
			return;
		}

		const CPath &parent_path = connection_path.get_node().get_parent_path();
		for( int i = 0; i < parent_path.get_number_of_elements(); i++ )
		{
			if( i >= new_path.get_number_of_elements() || new_path[ i ] != parent_path[ i ] )
			{
				/* new_path can't be targetted by this connection */
				return;
			}
		}

		CPath new_relative_path;
		for( int i = parent_path.get_number_of_elements(); i < new_path.get_number_of_elements(); i++ )
		{
			new_relative_path.append_element( new_path[ i ] );
		}
	
		characters_after_old_path = absolute_path_length - previous_path_length;
	
		ostringstream new_connection_path;
		new_connection_path << new_relative_path.get_string() << absolute_path.substr( previous_path_length );

		server.process_command( ISetCommand::create( connection_path.get_path(), CStringValue( new_connection_path.str() ) ), CCommandSource::SYSTEM );
	}
Exemplo n.º 23
0
void CFileDetailDialog::OnBnClickedApply(wxCommandEvent& WXUNUSED(evt))
{
	CPath fileName = CPath(CastChild(IDC_FILENAME, wxTextCtrl)->GetValue());

	if (fileName.IsOk() && (fileName != m_file->GetFileName())) {
		if (theApp->sharedfiles->RenameFile(m_file, fileName)) {
			FindWindow(IDC_FNAME)->SetLabel(MakeStringEscaped(m_file->GetFileName().GetPrintable()));
			FindWindow(IDC_METFILE)->SetLabel(m_file->GetFullName().GetPrintable());
			
			resetValueForFilenameTextEdit();
	
			Layout();
		}
	}
}
Exemplo n.º 24
0
bool CKnownFileList::Init()
{
	CFile file;

	CPath fullpath = CPath(theApp->ConfigDir + m_filename);
	if (!fullpath.FileExists()) {
		// This is perfectly normal. The file was probably either
		// deleted, or this is the first time running aMule.
		return false;
	}

	if (!file.Open(fullpath)) {
		AddLogLineC(CFormat(_("WARNING: %s cannot be opened.")) % m_filename);
		return false;
	}

	try {
		uint8 version = file.ReadUInt8();
		if ((version != MET_HEADER) && (version != MET_HEADER_WITH_LARGEFILES)) {
			AddLogLineC(_("WARNING: Known file list corrupted, contains invalid header."));
			return false;
		}

		wxMutexLocker sLock(list_mut);
		uint32 RecordsNumber = file.ReadUInt32();
		AddDebugLogLineN(logKnownFiles, CFormat(wxT("Reading %i known files from file format 0x%2.2x."))
			% RecordsNumber % version);
		for (uint32 i = 0; i < RecordsNumber; i++) {
			CScopedPtr<CKnownFile> record;
			if (record->LoadFromFile(&file)) {
				AddDebugLogLineN(logKnownFiles,
					CFormat(wxT("Known file read: %s")) % record->GetFileName());
				Append(record.release());
			} else {
				AddLogLineC(_("Failed to load entry in known file list, file may be corrupt"));
			}
		}
		AddDebugLogLineN(logKnownFiles, wxT("Finished reading known files"));

		return true;
	} catch (const CInvalidPacket& e) {
		AddLogLineC(_("Invalid entry in known file list, file may be corrupt: ") + e.what());
	} catch (const CSafeIOException& e) {
		AddLogLineC(CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what());
	}

	return false;
}
void Mouse(int button, int state,int x,int y)
{
	int mouse_tile_XPos=x/tile_size+g_XPos;
	int mouse_tile_YPos=y/tile_size+g_YPos;

	switch (button) 
	{ 
		case GLUT_LEFT_BUTTON: 
			if (state == GLUT_DOWN) 
			{
				//left clicked
				ClearTrack(true);

				map_tiles[mouse_tile_XPos][mouse_tile_YPos]=start;
						
			}
			break;
		case GLUT_RIGHT_BUTTON: 
			if (state == GLUT_DOWN ) 
			{
				//right clicked
				ClearTrack(false);

				//set the goal position
				map_tiles[mouse_tile_XPos][mouse_tile_YPos]=goal;

				//create the path
				pathCreator.SetObstructionMatrix(map_tiles,ground,start,goal);
				pathCreator.Create();
				pathL=pathCreator.BackTrack();
				//set the path to the map
				int i; 
				for(i=0;i<pathL.size()-1;i++)
				{
					map_tiles[pathL[i].X][pathL[i].Y]=track;
				}
				map_tiles[pathL[i].X][pathL[i].Y]=start;

				//clean the path list
				pathL.erase(pathL.begin(),pathL.begin()+pathL.size());


			}
			break; 
		default: 
			break; 
	} 
}
Exemplo n.º 26
0
    int ReadConfig(void) throw()
    {
        CPath path;

        if (GetIniFile(path))
        {
            int f = ::GetPrivateProfileInt(_T("server"), _T("family"), 0, path);
            m_family = (f == 4)? AF_INET : (f == 6)? AF_INET6 : DEFAULT_FAMILY;

            m_bCircular  = !!::GetPrivateProfileInt(_T("server"), _T("circular"), 0, path);
            m_MaxConnect = ::GetPrivateProfileInt(_T("server"), _T("maxconnect"), m_MaxConnect, path);

            CString buf;

            if (GetConfigString(buf, path, _T("ipaddress"))) { m_addr = buf; }

            if (GetConfigString(buf, path, _T("port"))) { m_port = buf; }

            if (GetConfigString(buf, path, _T("protocol")))
            {
                if (buf.CompareNoCase(_T("TCP")) == 0)
                {
                    m_socktype = SOCK_STREAM;
                }
                else if (buf.CompareNoCase(_T("UDP")) == 0)
                {
                    m_socktype = SOCK_DGRAM;
                }
            }

            // get storage name and interval
            CTask& task = CFactorySingleton<CTask>::Instance();

            UINT interval = ::GetPrivateProfileInt(_T("server"), _T("interval"), 0, path);

            if (interval > 0) { task.SetInterval(interval); }

            if (GetConfigString(buf, path, _T("storage"), STORAGE_NAME))
            {
                path.RemoveFileSpec();
                path.Append(buf);

                task.LoadState(path);
            }
        }

        return ERROR_SUCCESS;
    }
Exemplo n.º 27
0
bool CMapImportDlg::CheckInfile( ) {
	CString	strDescr;
	CFile	file( m_strSrcMap, CFile::modeRead | CFile::typeBinary );
//	m_TDI.m_strSrcDescr = _T("");
//	infoMap::iterator	i = m_infoMap.find( m_TDI.m_strMapType );
	bool	bRet = false;
//	switch( (*i).second.type ) {
	switch(0) {
	case 0: {
		}
		break;
	case 1 : {
			if( GetReferenced( file, strDescr, m_mapInfo ) ) {
				CPath	pathOfSrc( m_strSrcMap );
				m_mapInfo.m_strName = (LPCTSTR) pathOfSrc.Prefix();
				m_mapInfo.m_strIdent.Format( _T("TK@USRBEGK@%s"), (LPCTSTR) pathOfSrc.Prefix() );
				m_mapInfo.m_csType = tcsCS_Projected;
				m_mapInfo.m_csDatum = tcsGD_DeutscheHauptdreiecksnetz;
				m_mapInfo.m_csMeridian = tcsPM_Greenwich;
				m_mapInfo.m_csProjection = tcsPA_GaussKrueger;
				bRet = true;
			}
		}
		break;
	case 2 : {
			if( GetIntergraph( file, strDescr, m_mapInfo ) ) {
				CPath	pathOfSrc( m_strSrcMap );
				m_mapInfo.m_strName = (LPCTSTR) pathOfSrc.Prefix();
				m_mapInfo.m_strIdent.Format( _T("TK@USRBEGK@%s"), (LPCTSTR) pathOfSrc.Prefix() );
				m_mapInfo.m_csType = tcsCS_Projected;
				m_mapInfo.m_csDatum = tcsGD_DeutscheHauptdreiecksnetz;
				m_mapInfo.m_csMeridian = tcsPM_Greenwich;
				m_mapInfo.m_csProjection = tcsPA_GaussKrueger;
				bRet = true;
			}
		}
		break;
	}
	if( true == bRet ) {
		CPath	pathOfSrc( m_strSrcMap );
		CPath	pathOfDst;
//		pathOfDst.Dir( m_TDI.m_strDstDir );
//		pathOfDst.FileName( pathOfSrc.FileName() );
		m_mapInfo.m_strSrcPath = pathOfSrc.Path();
		m_mapInfo.m_strDstPath = pathOfDst.Path();
	}
	return bRet;
}
	void IFileContainer::write(const CPath& filename, const CPath& directory, ContentTypes::File& content) const
	{
		OOX::Rels::File rels;
		CPath current = filename.GetDirectory();
		write(rels, current, directory, content);
		rels.write(filename);
	}
Exemplo n.º 29
0
void CSharedFilesCtrl::OnRename( wxCommandEvent& WXUNUSED(event) )
{
	int item = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
	if ( item != -1 ) {
		CKnownFile* file = (CKnownFile*)GetItemData(item);

		wxString strNewName = ::wxGetTextFromUser(
			_("Enter new name for this file:"),
			_("File rename"), file->GetFileName().GetPrintable());

		CPath newName = CPath(strNewName);
		if (newName.IsOk() && (newName != file->GetFileName())) {
			theApp->sharedfiles->RenameFile(file, newName);
		}
	}
}
Exemplo n.º 30
0
bool CFile::Create(const CPath& path, bool overwrite, int accessMode)
{
	if (!overwrite && path.FileExists()) {
		return false;
	}

	return Open(path, write, accessMode);
}