Exemplo n.º 1
0
void Initialize()
{
    char buffer[_MAX_PATH];
    if (GetTempPath(sizeof(buffer), buffer) == 0) {
        g_sTempPath = "c:\\";
    }
    else {
        g_sTempPath = buffer;
    }

    g_bIsAdmin = ::IsAdmin();
    g_bIsWindowsNT = ::IsWindowsNT();
    
    g_bIE5 = (GetDllVersion("shdocvw.dll") >= PACKVERSION(5,0));
    // Guess which mode !
    g_sInternetMethod = (g_bIE5 ? "ie5" : "direct");

    // The TeXLive registry key
    g_sRegKey = ConcatPath( TEXLIVE_REGENTRY, TEXLIVE_VERSION);

    // VarTexmf will be stored in temp dir
    g_sVarTexmf = ConcatPath(g_sTempPath, "TeX\\texmf");

    // Get the cdrom texmf tree
    CString sDummyName;
    DWORD dwDummySize;
#ifdef TEST
	g_sTexmfMain = "e:\\TeXLive\\setupw32";
#else
    GetExecutableDirectory(g_sTexmfMain, sDummyName, dwDummySize);
#endif
    // Assume we are in \bin\win32 subdirectory, so:
    GetParentDirectory(g_sTexmfMain);
    GetParentDirectory(g_sTexmfMain);
    g_sDriveRootPath = g_sTexmfMain;
    g_sBinDir = ConcatPath(g_sTexmfMain, "bin\\win32");
    g_sSetupw32 = ConcatPath(g_sTexmfMain, "setupw32");
    g_sSupport = ConcatPath(g_sTexmfMain, "support");
    g_sTexmfMain = ConcatPath(g_sTexmfMain, "texmf");
    if (! DirectoryExists(g_sTexmfMain) ) {
        AfxMessageBox(IDS_NO_TEXLIVE_TEXMF, MB_OK | MB_ICONSTOP);
        exit(1);
    }
    if (! DirectoryExists(g_sBinDir) ) {
        AfxMessageBox(IDS_NO_TEXLIVE_BINARIES, MB_OK | MB_ICONSTOP);
        exit(1);
    }
    GetEditorLocation(g_sEditor);
}
Exemplo n.º 2
0
	string FileSystem::GetParentDirectory(const string& directory)
	{
		auto found	= directory.find_last_of("/\\");
		auto result	= directory;

		// If no slash was found, return provided string
		if (found == string::npos)
			return directory;

		// If the slash was find at the last position, remove it and try again
		if (found == directory.length() - 1)
		{
			result = result.substr(0, found - 1);
			return GetParentDirectory(result);
		}

		// Return parent directory including a slash at the end
		return result.substr(0, found) + "/";
	}
Exemplo n.º 3
0
bool __cdecl CleanupCDRom(LPVOID pParam)
{
    CString sTmp = g_sVarTexmf;
    GetParentDirectory(sTmp);
    RecursivelyRemove(sTmp);

#if 0
    CString sWinShellDir;
    if (! GetWinShellLocation(sWinShellDir) || ! DirectoryExists(sWinShellDir))
        return true;

    if (MessageBox(NULL, "Do you want to remove WinShell too ?", 
                   NULL, MB_YESNO | MB_ICONINFORMATION) == IDYES) {
        char buf[_MAX_PATH];
        CString sUninstCmd;
        for (int i = 0; i < 1000; i++) {
            wsprintf(buf, "unins%.3d.exe", i);
            sUninstCmd = ConcatPath(sWinShellDir, buf);
            if (! FileExists(sUninstCmd)) {
                i--;
                break;
            }
        }
        if (i > -1) {
            wsprintf(buf, "unins%.3d.exe", i);
            sUninstCmd = ConcatPath(sWinShellDir, buf);
            RunProcess(sUninstCmd, true);
            RecursivelyRemove(sWinShellDir);
        }
    }
#endif

    // Remove the registry key
    CRegistry theRegistry;
    if (theRegistry.Connect(HKEY_CURRENT_USER) == TRUE) {
        theRegistry.DeleteKey(g_sRegKey);
    }

    return true;
}
Exemplo n.º 4
0
bool __cdecl SetupEnv(LPVOID pParam)
{
    char buf[4096];
    CString sPath = g_sBinDir;
    sPath = GetSafePathName(sPath);
    sPath = sPath + ";";
    // Path
    GetEnvironmentVariable("PATH", buf, sizeof(buf));
    g_sDefaultPath = buf;
    sPath = sPath + buf;
    if (! g_sGhostscript.IsEmpty()) {
        char path[_MAX_PATH], *fp;
        // If not on the PATH, then add it
        if (SearchPath(buf, "gswin32c.exe", NULL, sizeof(path), path, &fp) == 0) {
            CString sGhostscriptBinDir = g_sGhostscript;
            sGhostscriptBinDir.Replace('/','\\');
            GetParentDirectory(sGhostscriptBinDir);
            // Remove terminating '\\' if needed
            if (sGhostscriptBinDir.Right(1) == "\\"
                && sGhostscriptBinDir.Right(2) != ":\\")
                sGhostscriptBinDir = sGhostscriptBinDir.Left(sGhostscriptBinDir.GetLength() - 1);
            // Retrieve safe path name for win9x users
            sGhostscriptBinDir = GetSafePathName(sGhostscriptBinDir, false);
            sPath = sPath + ";" + sGhostscriptBinDir;
        }
    }
    SetEnvironmentVariable("PATH", (LPCTSTR)sPath);

    CString sDir = ConcatPath(g_sVarTexmf, "web2c");
    SetEnvironmentVariable("TEXMFCNF", (LPCTSTR)sDir);

    SetEnvironmentVariable("TEXMFMAIN", (LPCTSTR)g_sTexmfMain);

    SetEnvironmentVariable("VARTEXMF", (LPCTSTR)g_sVarTexmf);

    return true;
}
Exemplo n.º 5
0
Arquivo: main.cpp Projeto: EQ4/axLib
void DirectoryNavigation::GoToParentDirectory()
{
	SetDestinationPath(GetParentDirectory());
}
Exemplo n.º 6
0
std::wstring CPathUtils::GetModuleDir( HMODULE hMod /*= nullptr*/ )
{
    return GetParentDirectory(GetModulePath(hMod));
}