コード例 #1
0
/* <269e8> ../engine/filesystem_internal.cpp:292 */
void FS_Rename(const char *originalName, const char *newName)
{
    char *cut;
    char localPath[512];
    char newPath[512];

    if (FS_GetLocalPath(originalName, localPath, ARRAYSIZE(localPath)))
    {
        Q_strcpy(newPath, localPath);
        cut = Q_strstr(newPath, originalName);

        if (cut)
        {
            *cut = 0;
#ifdef REHLDS_CHECKS
            Q_strncat(newPath, newName, ARRAYSIZE(newPath) - Q_strlen(newPath));
            newPath[ARRAYSIZE(newPath) - 1] = 0;
#else
            Q_strcat(newPath, newName);
#endif

            rename(localPath, newPath);
        }
    }
}
コード例 #2
0
void CServerRemoteAccess::GetMapList(CUtlBuffer &value)
{
	const char *findfn;
	char *extension;
	char curDir[MAX_PATH];
	char mapName[MAX_PATH];
	char mapwild[64];

	Q_strcpy(mapwild, "maps/*.bsp");
	for (findfn = Sys_FindFirst(mapwild, 0); findfn; findfn = Sys_FindNext(0))
	{
		Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn);
#ifdef REHLDS_CHECKS
		curDir[ARRAYSIZE(curDir) - 1] = 0;
#endif

		FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir));
		if (Q_strstr(curDir, com_gamedir))
		{
#ifdef REHLDS_CHECKS
			Q_strncpy(mapName, findfn, ARRAYSIZE(mapName));
			mapName[ARRAYSIZE(mapName) - 1] = 0;
#else
			Q_strcpy(mapName, findfn);
#endif
			extension = Q_strstr(mapName, ".bsp");
			if (extension)
				*extension = 0;

			value.PutString(mapName);
			value.PutString("\n");
		}
	}
	Sys_FindClose();

	value.PutChar(0);
}
コード例 #3
0
/* <26962> ../engine/filesystem_internal.cpp:282 */
void FS_Unlink(const char *filename)
{
    char localPath[512];
    FS_GetLocalPath(filename, localPath, 512);
    _unlink(localPath);
}
コード例 #4
0
ファイル: host.cpp プロジェクト: mefisto2009/rehlds
/* <35dc8> ../engine/host.c:409 */
void Host_WriteConfiguration(void)
{
#ifndef SWDS
	FILE *f;
	kbutton_t *ml;
	kbutton_t *jl;
	qboolean bSetFileToReadOnly;
	char nameBuf[4096];

	if (!host_initialized || g_pcls.state == ca_dedicated)
		return;

#ifdef _WIN32
	Sys_GetRegKeyValue("Software\\Valve\\Steam", "rate", rate_.string);
	if (cl_name.string && Q_stricmp(cl_name.string, "unnamed") && Q_stricmp(cl_name.string, "player") && Q_strlen(cl_name.string))
		Sys_GetRegKeyValue("Software\\Valve\\Steam", "LastGameNameUsed", cl_name.string);
#else
	SetRateRegistrySetting(rate_.string);
#endif // _WIN32
	if (Key_CountBindings() <= 1)
	{
		Con_Printf("skipping config.cfg output, no keys bound\n");
		return;
	}

	bSetFileToReadOnly = FALSE;
	f = FS_OpenPathID("config.cfg", "w", "GAMECONFIG");
	if (!f)
	{
		if (!developer.value || !FS_FileExists("../goldsrc/dev_build_all.bat"))
		{
			if (FS_GetLocalPath("config.cfg", nameBuf, sizeof(nameBuf)))
			{
				bSetFileToReadOnly = TRUE;
				chmod(nameBuf, S_IREAD|S_IWRITE);
			}
			f = FS_OpenPathID("config.cfg", "w", "GAMECONFIG");
			if (!f)
			{
				Con_Printf("Couldn't write config.cfg.\n");
				return;
			}
		}
	}

	FS_FPrintf(f, "// This file is overwritten whenever you change your user settings in the game.\n");
	FS_FPrintf(f, "// Add custom configurations to the file \"userconfig.cfg\".\n\n");
	FS_FPrintf(f, "unbindall\n");

	Key_WriteBindings(f);
	Cvar_WriteVariables(f);
	Info_WriteVars(f);

	ml = ClientDLL_FindKey("in_mlook");
	jl = ClientDLL_FindKey("in_jlook");

	if (ml && (ml->state & 1))
		FS_FPrintf(f, "+mlook\n");

	if (jl && (jl->state & 1))
		FS_FPrintf(f, "+jlook\n");

	FS_FPrintf(f, "exec userconfig.cfg\n");
	FS_Close(f);

	if (bSetFileToReadOnly)
	{
		FS_GetLocalPath("config.cfg", nameBuf, sizeof(nameBuf));
		chmod(nameBuf, S_IREAD);
	}
#endif // SWDS
}