-void RunBsp (char *command)
-{
- GPtrArray *sys;
- char batpath[BIG_PATH_MAX]; //% PATH_MAX
- char temppath[BIG_PATH_MAX]; //% PATH_MAX
- char name[BIG_PATH_MAX]; //% PATH_MAX
- char cWork[BIG_PATH_MAX]; //% PATH_MAX
- FILE *hFile;
- unsigned int i;
-
- SetInspectorMode(W_CONSOLE);
-
- strcpy (temppath, g_strTempPath.GetBuffer ());
-
- SaveWithRegion(name);
-
- const char *rsh = ValueForKey(g_qeglobals.d_project_entity, "rshcmd");
- if (rsh == NULL)
- {
- CString strPath, strFile;
-
- ExtractPath_and_Filename(name, strPath, strFile);
- AddSlash(strPath);
- strncpy(cWork, strPath, 1024);
- strcat(cWork, strFile);
- } else
- {
- strcpy(cWork, name);
- }
-
- // get the array ready
- //++timo TODO: free the array, free the strings ourselves with delete[]
- sys = g_ptr_array_new();
-
- QE_ExpandBspString (command, sys, cWork);
-
- if (g_PrefsDlg.m_bWatchBSP)
- {
- // grab the file name for engine running
- char *bspname = new char[1024];
- ExtractFileName( currentmap, bspname );
- StripExtension( bspname );
- g_pParentWnd->GetWatchBSP()->DoMonitoringLoop( sys, bspname );
- } else
- {
- // write all the steps in a single BAT / .sh file and run it, don't bother monitoring it
- CString strSys;
- for (i=0; i < sys->len; i++ )
- {
- strSys += (char *)g_ptr_array_index( sys, i);
-#ifdef _WIN32 // write temp\junk.txt in win32... NOTE: stops output to shell prompt window
- if (i==0)
- strSys += " >";
- else
- strSys += " >>";
- strSys += "\"";
- strSys += temppath;
- strSys += "junk.txt\"";
-#endif
- strSys += "\n";
- };
-
-#if defined (__linux__) || defined (__APPLE__)
-
- // write qe3bsp.sh
- sprintf (batpath, "%sqe3bsp.sh", temppath);
- Sys_Printf("Writing the compile script to '%s'\n", batpath);
- Sys_Printf("The build output will be saved in '%sjunk.txt'\n", temppath);
- hFile = fopen(batpath, "w");
- if (!hFile)
- Error ("Can't write to %s", batpath);
- fprintf (hFile, "#!/bin/sh \n\n");
- fprintf (hFile, strSys.GetBuffer());
- fclose (hFile);
- chmod (batpath, 0744);
-#endif