Compare commits

..

4 Commits

Author SHA1 Message Date
ptitSeb
a9ed0adf37
Merge pull request #75 from twolife/execv
reload ourself when selecting a Mod
2025-02-17 09:31:32 +01:00
ptitSeb
4ec7de1272
Merge pull request #74 from twolife/directory_path
implement MakeSureDirectoryPathExists()
2025-02-17 09:29:35 +01:00
Sébastien Noel
2c704cd6a9 reload ourself when selecting a Mod 2025-02-17 09:14:50 +01:00
Sébastien Noel
36778432b8 implement MakeSureDirectoryPathExists() 2025-02-17 08:58:48 +01:00
2 changed files with 32 additions and 14 deletions

View File

@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <filesystem>
// !!! FIXME : rcg10162001 Need this anymore, since _findfirst() is abstracted?
#ifdef PLATFORM_WIN32
@ -918,7 +919,13 @@ void CTFileStream::Open_t(const CTFileName &fnFileName, CTStream::OpenMode om/*=
static void MakeSureDirectoryPathExists(const CTFileName &fnmFullFileName)
{
STUBBED("!!! FIXME: get the code back in from Ryan's original port.");
CTFileName fnDirectory = fnmFullFileName.FileDir();
const char *path = (const char *) (CTString&)fnDirectory;
std::error_code ec;
std::filesystem::create_directories(path, ec);
if (ec) {
FatalError("Cannot create directory path:\n%s", path);
}
}
/*

View File

@ -1364,8 +1364,11 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
void CheckModReload(void)
{
#ifdef PLATFORM_WIN32
if (_fnmModToLoad!="") {
CTString strMod = _fnmModToLoad.FileName();
const char *argv[9];
int i = 0;
#ifdef PLATFORM_WIN32
#ifndef NDEBUG
CTString strDebug = "Debug\\";
#else
@ -1373,25 +1376,33 @@ void CheckModReload(void)
#endif
CTString strCommand = _fnmApplicationPath+"Bin\\"+strDebug+"SeriousSam.exe";
//+mod "+_fnmModToLoad.FileName()+"\"";
CTString strMod = _fnmModToLoad.FileName();
const char *argv[7];
argv[0] = strCommand;
argv[1] = "+game";
argv[2] = strMod;
argv[3] = NULL;
argv[i++] = strCommand;
#else
argv[i++] = argv0;
#endif
argv[i++] = "+game";
argv[i++] = strMod;
argv[i] = NULL;
if (_fnmCDPath!="") {
argv[i++] = "+cdpath";
argv[i++] = _fnmCDPath;
argv[i] = NULL;
}
if (_strModServerJoin!="") {
argv[3] = "+connect";
argv[4] = _strModServerJoin;
argv[5] = "+quickjoin";
argv[6] = NULL;
argv[i++] = "+connect";
argv[i++] = _strModServerJoin;
argv[i++] = "+quickjoin";
argv[i] = NULL;
}
#ifdef PLATFORM_WIN32
_execv(strCommand, argv);
MessageBoxA(0, "Error launching the Mod!\n", "Serious Sam", MB_OK|MB_ICONERROR);
}
#else
STUBBED("reload ourself?");
execv(argv0, (char* const*)argv);
fprintf(stderr, "Error launching Mod '%s'! execv(%s, ...)\n", strMod, argv0);
#endif
}
}
void CheckTeaser(void)