Beispiel #1
0
// Makes ALL the directories! \o/
void Instance::MkDirs()
{
    if (!GetRootDir().DirExists())
        GetRootDir().Mkdir();

    if (!GetMCDir().DirExists())
        GetMCDir().Mkdir();
    if (!GetBinDir().DirExists())
        GetBinDir().Mkdir();
    if (!GetSavesDir().DirExists())
        GetSavesDir().Mkdir();
    if (!GetMLModsDir().DirExists())
        GetMLModsDir().Mkdir();
    if (!GetCoreModsDir().DirExists())
        GetCoreModsDir().Mkdir();
    if (!GetResourceDir().DirExists())
        GetResourceDir().Mkdir();
    if (!GetScreenshotsDir().DirExists())
        GetScreenshotsDir().Mkdir();
    if (!GetTexturePacksDir().DirExists())
        GetTexturePacksDir().Mkdir();

    if (!GetInstModsDir().DirExists())
        GetInstModsDir().Mkdir();
}
Beispiel #2
0
wxFileName Instance::GetMCDir() const
{
	wxFileName mcDir;
	
	if (ENUM_CONTAINS(wxPlatformInfo::Get().GetOperatingSystemId(), wxOS_MAC) || 
		wxFileExists(Path::Combine(GetRootDir(), _("minecraft"))))
	{
		mcDir = wxFileName::DirName(Path::Combine(GetRootDir(), _("minecraft")));
	}
	else
	{
		mcDir = wxFileName::DirName(Path::Combine(GetRootDir(), _(".minecraft")));
	}
	
	return mcDir;
}
BOOL CDlgBatteryParam::OnInitDialog() 
{
	CDialog::OnInitDialog();

    m_batteryCell = -1;

    GetPrivateProfileStringW(_T("Prompt"),_T("MESSAGE_TITLE"),_T("MESSAGE_TITLE"),
        m_strMsgBoxTitle.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);

	int n;
	LPWSTR lpDir;
	CString strTempPath;
	CString strSystemPath;
	lpDir=GetRootDir();
	strSystemPath = (CString)lpDir;
	if(lpDir)
	{
		delete lpDir;
	}
	n = strSystemPath.ReverseFind('\\');
    strTempPath = strSystemPath.Left(n);
    n = strTempPath.ReverseFind('\\');
    strRootPath=strTempPath.Left(n);
	strResourceDtsPath= strRootPath+_T("\\dts\\Resource.dts");
	strResourceDtbPath= strRootPath+_T("\\dts\\rk-kernel.dtb");
	strResourcePath=strTempPath+"\\Android\\Image\\resource.img";

    InitUIComponents();

    //ReadBatteryParameters();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #4
0
wxFileName Instance::GetMCDir() const
{
    wxFileName mcDir;

    wxString dotMCDir = Path::Combine(GetRootDir(), ".minecraft");
    wxString nodotMCDir = Path::Combine(GetRootDir(), "minecraft");

    if (wxDirExists(dotMCDir) && !wxDirExists(nodotMCDir))
    {
        mcDir = wxFileName::DirName(dotMCDir);
    }
    else
    {
        mcDir = wxFileName::DirName(nodotMCDir);
    }

    return mcDir;
}
bool IsAdminRequired(void)
{
	TCHAR path[MAX_PATH];
	GetRootDir(path);
	_tcscat(path, _T("\\test_tmp.tmp"));

	HANDLE hDatFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0);
	if (hDatFile != INVALID_HANDLE_VALUE) 
	{
		CloseHandle(hDatFile);
		DeleteFile(path);
		return false;
	}

	return true;
}
Beispiel #6
0
STI8Version& CSystemInfo::GetI8Version()
{
	stdex::tString strPath;
	strPath = GetRootDir();

	tstrcpy(m_stI8Version.szCltSvrVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\i8deskclisvr.exe")).c_str());
	tstrcpy(m_stI8Version.szCltUIVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\Baronline.exe")).c_str());
#ifdef _DEBUG
    tstrcpy(m_stI8Version.szCltDataVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\I8ClientDataCoreD.dll")).c_str());
#else
    tstrcpy(m_stI8Version.szCltDataVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\I8ClientDataCore.dll")).c_str());
#endif

	strPath = GetSystemDir();
    tstrcpy(m_stI8Version.szProtVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\drivers\\wxProt.sys")).c_str());
    tstrcpy(m_stI8Version.szVirtualDiskVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\drivers\\wxNda.sys")).c_str());

	return m_stI8Version;
}
Beispiel #7
0
QByteArray QFileIOService::ExecuteRDSCommand(QRDSServer &rdsserver, quint8 command, const QMap<QString, QString> &map)
{
    QByteArray ret;

    switch (command)
    {
    case QBrowseDirCommand:
        return BrowseDir(rdsserver, map);
        break;
    case QFileReadCommand:
        return FileRead(rdsserver, map);
        break;
    case QFileWriteCommand:
        return FileWrite(rdsserver, map);
        break;
    case QFileRenameCommand:
        return FileRename(rdsserver, map);
        break;
    case QFileRemoveFileCommand:
        return FileRemove(rdsserver, map, true);
        break;
    case QFileRemoveDirectoryCommand:
        return FileRemove(rdsserver, map, false);
        break;
    case QFileExistCommand:
        return Existence(rdsserver, map);
        break;
    case QFileCreateDirCommand:
        return CreateDir(rdsserver, map);
        break;
    case QFileGetRootDirCommand:
        return GetRootDir(rdsserver);
        break;
    }

    return ret;
}
Beispiel #8
0
wxFileName Instance::GetModListFile() const
{
	return wxFileName::FileName(Path::Combine(GetRootDir(), _("modlist")));
}
Beispiel #9
0
wxFileName Instance::GetInstModsDir() const
{
	return wxFileName::DirName(Path::Combine(GetRootDir().GetFullPath(), _("instMods")));
}
Beispiel #10
0
void CxpGbaDlg::OnOK() 
{
	CString logpath;
	
	GetRootDir(logpath);
	logpath += "\\gxplog.txt";


	FILE *fp= fopen(logpath, "w");
	if(fp)
		log_init(LOG_STATUS, fp);

	if(Validate() == FALSE)
	{
		if(fp)
		{
			log_exit();
			fclose(fp);
		}		
		return;
	}

	GritShared *grs= mgr->shared;

	// Read external tileset if required
	// PONDER: move inside grit_run?
	if(mgr->gfxIsShared)
	{
		// read file
		grs->dib= dib_load(grs->tilePath, NULL);

		if(grs->dib)
		{
			if( dib_get_bpp(grs->dib) != 8 )
			{
				lprintf(LOG_WARNING, "  External tileset must be 8bpp. Converting.\n");
				dib_convert(grs->dib, 8, 0);
			}

			if( dib_get_width(grs->dib) != 8 )
			{
				lprintf(LOG_WARNING, "  External tileset not tiled yet. Doing so now.\n");
				dib_redim(grs->dib, 8, 8, 0);
			}
		}
		else
			lprintf(LOG_WARNING, "  Couldn't load external tileset from \n    %s.\n", 
				grs->tilePath);

		// PONDER: reduce here too?
	}

	int res= grit_run(mgr);

	// Save external tileset if required
	// PONDER: move inside grit_run?
	if(mgr->gfxIsShared)
	{
		if( !dib_save(grs->dib, grs->tilePath, NULL) )
			lprintf(LOG_WARNING, "  Couldn't save external tileset to \n    %s.\n", 
				grs->tilePath);
	}


	if(fp)
	{
		log_exit();
		fclose(fp);
	}

	if(res == TRUE)
	{
		// PONDER: ask to see log?
		res= MessageBox("Export succeeded. Show log?", NULL, 
			MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2);	
		if(res == IDYES)
		{
			CLogDlg dlg;
			dlg.SetTextFromFile(logpath);
			dlg.DoModal();
		}
		CDialog::OnOK();
	}
	else
	{
		// PONDER: ask to see log?
		res= MessageBox("Export failed. Show Log?", NULL, 
			MB_ICONEXCLAMATION | MB_YESNO);	
		if(res == IDYES)
		{
			CLogDlg dlg;
			dlg.SetTextFromFile(logpath);
			dlg.DoModal();
		}	
	}
}
Beispiel #11
0
void AppendToRootDir(WCHAR* result, const WCHAR *b) {
    WCHAR* a = GetRootDir();
    Concat(result, a, b);
}
Beispiel #12
0
void CheckForUpdatesWorker(void *param)
{
	if (checking) return;
	/*
	// this check doesn't work on some systems - not sure which or why
	if(!(GetSystemMetrics(SM_NETWORK) & 1)) {
		ShowError(TranslateT("No network - aborting update check"));
		NLog("worker thread aborting - no network");
		return 1; // no network
	}
	*/

	NLog("CheckForUpdatesWorker thread starting");

	checking = true;

	WriteLastCheckTime();

	bool confirm = !(((DWORD)param & 1) == 1);
	bool restart = !(((DWORD)param & 2) == 2); // if restart is false, then we're doing an 'update and shutdown'

	if(hwndOptions) PostMessage(hwndOptions, WMU_CHECKING, 0, 0);

	bool use_popup = options.popup_notify && ArePopupsEnabled();
	
	FilenameMap fn_map(5, CompareFileNameStruct);
	
	if (use_popup) 
	{
		ShowPopup(0, TranslateT("Checking for Updates"), _T(""), POPFLAG_SAVEHWND, -1);
	} 
	else 
	{
		CreateProgressWindow();

		SendMessage(hwndProgress, WM_SETTEXT, 0, (LPARAM)TranslateT("Progress - Checking for updates..."));
		if (options.use_xml_backend) SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Downloading XML data"), 0);
		else SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Checking for updates"), 0);

	}
	
	EnterCriticalSection(&list_cs);

	if (options.use_xml_backend)	
    {
		if (UpdateXMLData(MC_PLUGINS)) // prevent double error messages (in some cases)
		{
			// iterate through the registered plugins
			if (!use_popup) SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Scanning plugins folder"), 0);
			ScanPlugins(&fn_map, &update_list);

			if (UpdateXMLData(MC_LOCALIZATION)) 
			{
				if (!use_popup) SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Scanning language packs"), 0);
				ScanLangpacks(&fn_map, &update_list);
			}

			if(!use_popup) SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Updating component file listing ids"), 0);
			UpdateFLIDs(update_list);
		}

		if (!use_popup) SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Checking for updates"), 0);
	}

	UpdateList update_list2(update_list);
	LeaveCriticalSection(&list_cs);

	int count = update_list2.getCount(), index = 0;
	TCHAR msg[512];
	TCHAR *temp_str;

	UpdateList todo;

	for(index = 0; index < count; index++) 
	{
		if(update_list2[index].update_options.enabled) 
		{
			mir_sntprintf(msg, SIZEOF(msg), TranslateT("Checking plugin: %s"), (temp_str = GetTString(update_list2[index].update.szComponentName)));
			mir_free(temp_str);
		} 
		else 
		{
			mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), (temp_str = GetTString(update_list2[index].update.szComponentName)));
			mir_free(temp_str);
		}

		if(!use_popup) {
			SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)msg, 0);
			SendMessage(hwndProgress, WMU_SETPROGRESS, (WPARAM)(int)(index * 100.0 / count), 0);
		} //else if(hwndPop) // disabled - just annoying
			//ChangePopupText(hwndPop, msg);

		if (update_list2[index].update_options.enabled) 
		{
			char *nv;
			bool beta;
			if (nv =  UpdateRequired(update_list2[index], &beta)) 
			{
				todo.insert(new UpdateInternal(update_list2[index]));			
				todo[todo.getCount()-1].newVersion = nv;
				todo[todo.getCount()-1].update_options.use_beta = beta;
			}
		}
		if (!use_popup && hwndProgress == NULL) 
		{
			RemoveFolder(options.temp_folder);
			break; // user closed progress window - cancel
		}
	}

	ProgressWindowDone();
	if (hwndPop) PostMessage(hwndPop, WMU_CLOSEPOP, 0 , 0);
	
	if(options.use_xml_backend) {
		FreeXMLData(MC_PLUGINS);
		FreeXMLData(MC_LOCALIZATION);
	}

	bool restore_status = true;

	if (todo.getCount()) 
	{
		int cd_ret = CD_OK;
		if (confirm) 
		{
			if (use_popup) 
			{
				ShowPopup(0, TranslateT("Updates Available"), TranslateT("Updated Miranda components detected.\nClick here to install."), POPFLAG_SAVEHWND, -1);
				DWORD ret;
				while ((ret = WaitForSingleObject(hEventPop, 200)) == WAIT_TIMEOUT && !Miranda_Terminated());

				if (!pop_cancelled && ret == WAIT_OBJECT_0 && !Miranda_Terminated()) 
				{
					cd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMUPDATES), GetDesktopWindow(), DlgProcConfirm, (LPARAM)&todo);
				} 
				else 
				{
					if(hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
					RestoreStatus();
					for(int i=0; i<todo.getCount(); ++i)
						free(todo[i].newVersion);
					checking = false;
					Netlib_CloseHandle(hNetlibHttp);
					hNetlibHttp = NULL;
					return;
				}
			} 
			else
				cd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMUPDATES), GetDesktopWindow(), DlgProcConfirm, (LPARAM)&todo);
		}



		if (!confirm || cd_ret == CD_CONFALL || cd_ret == CD_NOINSTALL || cd_ret == CD_OK) 
		{	
			bool conf_all = (cd_ret == CD_CONFALL), no_install = (cd_ret == CD_NOINSTALL);

			// ensure the backup folder exists (either create it or return non-zero signifying error)
			if (options.backup && !CreatePath(options.backup_folder)) 
			{
				//MessageBox(0, Translate("Could not create backup folder"), Translate("Error"), MB_OK | MB_ICONERROR);
				ShowError(TranslateT("Could not create backup folder"));
				if (hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
				RestoreStatus();
				for (int i=0; i<todo.getCount(); ++i)
					free(todo[i].newVersion);
				checking = false;
				Netlib_CloseHandle(hNetlibHttp);
				hNetlibHttp = NULL;
				return;
			}

			bool dll_enabled_or_langpack = DownloadUpdates(todo, &fn_map, confirm ? false : options.auto_dll_only);
			if (todo.getCount() && !no_install) 
			{
				if (!conf_all || DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIRMCOMPONENTS), GetDesktopWindow(), DlgProcConfirmComponents) == IDOK) 
				{
					if (!dll_enabled_or_langpack && restart)
					{ 
						// we're not doing an 'update and shutdown', and we're not updating any active dlls...so just install

						// get folders
						TCHAR root_folder[MAX_PATH], plugins_folder[MAX_PATH];

						GetRootDir(root_folder);

						_tcscpy(plugins_folder, root_folder);
						_tcscat(plugins_folder, _T("\\Plugins"));

						// move files
						MoveFiles(0, options.temp_folder, plugins_folder, options.backup_folder, root_folder);
						
						// rescan to get correct version numbers
						ScanPlugins(0, 0);	
					} 
					else 
					{
						if (ExternProcess(restart) == 0) // if restarting, don't restore status
							restore_status = false;
					}
				}
			}
		}

		for (int i=0; i<todo.getCount(); ++i)
			free(todo[i].newVersion);

	} 
	else if (!restart) 
	{
		PostMessage((HWND)CallService(MS_CLUI_GETHWND, 0, 0), WM_COMMAND, ID_ICQ_EXIT, 0);
	}	

	if (restore_status && restart) // restore status if we're not doing an 'update and shutdown', and the update was unsuccessful (or there was nothing to update, or no need to shutdown)
	{
		checking = false;
		if (hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
		RestoreStatus();
	}
	Netlib_CloseHandle(hNetlibHttp);
	hNetlibHttp = NULL;
}
int SetupHelperApp::OnRun()
{
#ifdef _WIN64
    DBG("--- x64 SetupHelper");
#else
    DBG("--- x86 SetupHelper");
#endif
    
    if (__argc < 3)
        return -1;

    std::vector<ProcessInfo> processes;
    DBG("Get processes (1)"); 
    if (!GetProcesses(processes))
        return -1;
    DBG("Got processes (1):");
    for (size_t i = 0; i < processes.size(); ++i)
    {
        DBG(i << ": " << processes[i].pid);
    }

    // Kill all Explorer and cvslock processes
    
    for (size_t i = 0; i < processes.size(); ++i)
    {
        if (!_tcsicmp(processes[i].image.c_str(), wxT("explorer.exe")))
        {
            DBG("Killing Explorer");
            // Show dialog
            wxProgressDialog* dlg = new wxProgressDialog(wxT("TortoiseCVS Setup"), wxText(__argv[1]));
            dlg->Show();
            // Kill Explorer
            TerminateProcess(processes[i]);
            int i = 0;
            while (IsProcessRunning(processes[i].pid) && (i < 50))
            {
                dlg->Update((i+1)*100/50);
                Sleep(50);
            }
            
            // Avoid the Active Desktop error message
            HKEY hKey;
            if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
                              0, KEY_WRITE, &hKey))
            {
                DWORD data = 0;
                RegSetValueExA(hKey, "FaultKey", 0, REG_DWORD, reinterpret_cast<BYTE*>(&data), sizeof(DWORD));
            }

            dlg->Destroy();
        }
        else if (!_tcsicmp(processes[i].image.c_str(), wxT("cvslock.exe")))
        {
            // Kill CVSNT lock service
            TerminateProcess(processes[i]);
        }
    }

    // Show dialog
    wxProgressDialog* dlg = new wxProgressDialog(wxT("TortoiseCVS Setup"), wxText(__argv[1]));
    dlg->Show();

    // Wait for Explorer restart
    for (int i = 0; i < 50; ++i)
    {
       if (IsExplorerRunning())
          break;
       dlg->Update((i+1)*100/50);
       Sleep(50);
    }
    if (!IsExplorerRunning())
    {
       dlg->Update(0);
       STARTUPINFOA startupinfo;
       startupinfo.cb = sizeof(STARTUPINFOA);
       startupinfo.lpReserved = 0;
       startupinfo.lpDesktop = 0;
       startupinfo.lpTitle = 0;
       startupinfo.dwFlags = 0;
       startupinfo.cbReserved2 = 0;
       startupinfo.lpReserved2 = 0;
       PROCESS_INFORMATION processinfo;
       CreateProcessA(0, "explorer.exe", 0, 0, FALSE, 0, 0, 0, &startupinfo, &processinfo);
       CloseHandle(processinfo.hProcess);
       CloseHandle(processinfo.hThread);
       for (int i = 0; i < 10; ++i)
       {
          Sleep(50);
          dlg->Update((i+1)*100/10);
       }
    }
    dlg->Destroy();
    
    DBG("Check remaining processes");
    bool anyLeft = true;
    while (anyLeft)
    {
        processes.clear();
        DBG("Get processes (2)");
        if (!GetProcesses(processes))
            return -1;
        DBG("Got processes (2):");
        for (size_t i = 0; i < processes.size(); ++i)
        {
            DBG(i << ": " << processes[i].pid);
        }
        
        anyLeft = false;
        for (size_t i = 0; i < processes.size(); ++i)
        {
            if (_tcsicmp(processes[i].image.c_str(), wxT("explorer.exe")))
            {
                anyLeft = true;
                // Ask user to close application
                wxString msg;
                msg << wxT("The application ");
                if (processes[i].title.empty())
                {
                    // No title found (may be minimized to tray etc.)
                    msg << processes[i].image;
                }
                else
                    msg << wxT("'") << processes[i].title << wxT("' (") << processes[i].image << wxT(")");
                msg << wxT("\nneeds to be closed before TortoiseCVS setup can continue.\n")
                    << wxT("Please close the application and click OK, or click Cancel to leave the process ")
                    << wxT("running.\nIn the latter case, you will be required to reboot Windows after installation.");
                if (MessageBox(0, msg.c_str(), wxT("TortoiseCVS Setup"), MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL)
                    return 1;
            }
        }
    }

    DBG("Loop done");

    if (__argv[2][0] == 'b')
        return 0;

    // Delete any renamed DLL's
    // TODO: Make this work even when installing to a different directory
    std::string rootDir(GetRootDir());
    std::string src(rootDir);
    src += "TortoiseShell.dll_renamed";
    DBG("Deleting " << src);
    DeleteFileA(src.c_str());
    src = rootDir;
    src += "TortoiseShell64.dll_renamed";
    DBG("Deleting " << src);
    DeleteFileA(src.c_str());
    src = rootDir;
    src += "TortoiseAct.exe_renamed";
    DBG("Deleting " << src);
    DeleteFileA(src.c_str());

    DBG("Exit: 0");
    return 0;
}