Exemplo n.º 1
0
extern "C" void DirInit (void)
{
	CfgStruct cfg;
	int rv;
	char *pTok;
	char pBuf[256];
	char pBuf2[256];

	// Working directory hack for shareware version

	if (_access ("mission.dat", 4) != 0) {
		//MessageBox (NULL, "Warning - JJFFE not installed correctly",
		//	"WinFFE startup error", MB_OK | MB_ICONWARNING);
		_chdir ("game");
	}

	CfgOpen (&cfg, __CONFIGFILE__);
	CfgFindSection (&cfg, "DIR");

	rv = CfgGetKeyStr (&cfg, "AVIPath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		WinDirFixPath (pBuf, pDirAVIPath);
	}
	else WinDirFixPath (pDirAVIPathDef, pDirAVIPath);

	rv = CfgGetKeyStr (&cfg, "CmmdrPath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		WinDirFixPath (pBuf, pDirCmmdrPath);
	}
	else WinDirFixPath (pDirCmmdrPathDef, pDirCmmdrPath);

	rv = CfgGetKeyStr (&cfg, "SamplePath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		WinDirFixPath (pBuf, pDirSamplePath);
	}
	else WinDirFixPath (pDirSamplePathDef, pDirSamplePath);

	rv = CfgGetKeyStr (&cfg, "SongPath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		WinDirFixPath (pBuf, pDirSongPath);
	}
	else WinDirFixPath (pDirSongPathDef, pDirSongPath);

	CfgClose (&cfg);

	// Test for directory presence

	_getcwd (pBuf, 255);
	if (_chdir (pDirCmmdrPath) != 0) {
		WinDirFixPath (pBuf, pDirCmmdrPath);
	}
	strcpy (pDirCmmdrPathSys, pDirCmmdrPath);

	// Read drive letters

	WinDirAddDrive ("A:\\", 6);
	strcpy (pBuf2, "C:\\");
	while (_chdir (pBuf2) == 0) {
		WinDirAddDrive (pBuf2, 6);
		pBuf2[0]++;
	}
	_chdir (pBuf);

}
Exemplo n.º 2
0
void DirInit (void)
{
	CfgStruct cfg;
	int rv;
	char *pTok;
	char pBuf[256];

	FILE *pFile = fopen ("mission.dat", "rb");
	if (pFile == NULL) chdir ("game");
	else fclose (pFile);

	CfgOpen (&cfg, __CONFIGFILE__);
	CfgFindSection (&cfg, "DIR");

	rv = CfgGetKeyStr (&cfg, "AVIPath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		LinuxDirFixPath (pBuf, pDirAVIPath);
	}
	else LinuxDirFixPath (pDirAVIPathDef, pDirAVIPath);

	rv = CfgGetKeyStr (&cfg, "CmmdrPath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		LinuxDirFixPath (pBuf, pDirCmmdrPath);
	}
	else LinuxDirFixPath (pDirCmmdrPathDef, pDirCmmdrPath);

	rv = CfgGetKeyStr (&cfg, "SamplePath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		LinuxDirFixPath (pBuf, pDirSamplePath);
	}
	else LinuxDirFixPath (pDirSamplePathDef, pDirSamplePath);

	rv = CfgGetKeyStr (&cfg, "SongPath", pBuf, 255);
	if (rv != 0) {
		pTok = strtok (pBuf, " \n\t");
		strcpy (pBuf, pTok);
		LinuxDirFixPath (pBuf, pDirSongPath);
	}
	else LinuxDirFixPath (pDirSongPathDef, pDirSongPath);


	// Test for directory presence

	getcwd (pBuf, 255);
	if (chdir (pDirCmmdrPath) != 0) {
		getcwd (pDirCmmdrPath, 255);
		strcat (pDirCmmdrPath, "/");
	}
	strcpy (pDirCmmdrPathSys, pDirCmmdrPath);
	chdir (pBuf);

	// Read drive letters

	CfgClose (&cfg);
}