コード例 #1
0
ファイル: cl_demos_auto.cpp プロジェクト: redsaurus/jaMME
void demoAutoSaveLast_f(void) {
	if (Cmd_Argc() < 2 && FS_CopyFile(va("%s/demos/LastDemo/LastDemo.dm_26", demo.record.mod), va("%s/demos/%s.dm_26", demo.record.mod, demoAutoGenerateDefaultFilename()), NULL, 0)) {
		Com_Printf(S_COLOR_GREEN"LastDemo successfully saved\n");
	} else if (FS_CopyFile(va("%s/demos/LastDemo/LastDemo.dm_26", demo.record.mod), va("%s/demos/%s.dm_26", demo.record.mod, Cmd_Argv( 1 )), NULL, 0)) {
		Com_Printf(S_COLOR_GREEN"LastDemo successfully saved into %s.dm_26\n", Cmd_Argv( 1 ));
	} else {
		Com_Printf(S_COLOR_RED"LastDemo has failed to save\n");
	}
}
コード例 #2
0
ファイル: cl_demos_auto.cpp プロジェクト: redsaurus/jaMME
void demoAutoComplete(void) {
	CL_StopRecord_f();
	char newName[MAX_QPATH];
	//if we are not manually saving, then temporarily store a demo in LastDemo folder
	if (!*demo.record.demoName && FS_CopyFile(va("%s/demos/%s.dm_26", demo.record.mod, demo.record.defaultName), va("%s/demos/LastDemo/LastDemo.dm_26", demo.record.mod), NULL, 0)) {
		Com_Printf(S_COLOR_GREEN"Demo temporarily saved into LastDemo/LastDemo.dm_26\n");
	} else if (FS_CopyFile(va("%s/demos/%s.dm_26", demo.record.mod, demo.record.defaultName), va("%s/demos/%s.dm_26", demo.record.mod, demo.record.demoName), newName, sizeof(newName))) {
		Com_Printf(S_COLOR_GREEN"Demo successfully saved into %s.dm_26\n", (Q_stricmp(newName, "")) ? newName : demo.record.demoName);
	} else {
		Com_Printf(S_COLOR_RED"Demo has failed to save\n");
	}
}
コード例 #3
0
ファイル: QuakeFileSystem.cpp プロジェクト: RkShaRkz/Quake2
void FS_CopyFiles(const char *srcMask, const char *dstDir)
{
	FSLog->Printf("CopyFiles(%s->%s)\n", srcMask, dstDir);

	TString<256> Base; Base.filename(srcMask);
	char *s = Base.rchr('/');
	if (!s) s = Base;
	else s++;								// will point to mask start

	// prepare dst string: should ends with '/'
	TString<256> Pattern; Pattern.filename(dstDir);
	int pos = Pattern.len();
	if (!pos || Pattern[pos - 1] != '/')
		Pattern[pos++] = '/';

	appMakeDirectoryForFile(Pattern);
#if 1
	CFileList *list = new CFileList;
	appListDirectory(srcMask, *list, FS_FILE);
#else
	CFileList *list = GFileSystem->List(srcMask, FS_OS);
#endif
	for (TListIterator<CFileItem> it = *list; it; ++it)
	{
		strcpy(s, it->name);				// create source filename
		strcpy(Pattern + pos, it->name);	// create destination filename
		FS_CopyFile(Base, Pattern);
	}
	delete list;
}
コード例 #4
0
ファイル: cl_demos_auto.cpp プロジェクト: Daggolin/jk2mv
void demoAutoSaveLast_f(void) {
	if (Cmd_Argc() < 2
		&& FS_CopyFile(
			va("%s/demos/%s%s", demoAuto.mod, DEFAULT_NAME_LAST, demoAuto.ext),
			va("%s/demos/%s%s", demoAuto.mod, demoAutoGenerateDefaultFilename(), demoAuto.ext)
		)) {
		Com_Printf(S_COLOR_GREEN "LastDemo successfully saved\n");
	} else if (
		FS_CopyFile(
			va("%s/demos/%s%s", demoAuto.mod, DEFAULT_NAME_LAST, demoAuto.ext),
			va("%s/demos/%s%s", demoAuto.mod, Cmd_Argv( 1 ), demoAuto.ext)
		)) {
		Com_Printf(S_COLOR_GREEN "LastDemo successfully saved into %s%s\n", Cmd_Argv( 1 ), demoAuto.ext);
	} else {
		Com_Printf(S_COLOR_RED "LastDemo has failed to save\n");
	}
}
コード例 #5
0
ファイル: cl_demos_auto.cpp プロジェクト: Daggolin/jk2mv
void demoAutoComplete(void) {
	char newName[MAX_OSPATH];
	CL_StopRecord_f();
	//if we are not manually saving, then temporarily store a demo in LastDemo folder
	if (!demoAuto.demoName[0]
		&& FS_CopyFile(
			va("%s/demos/%s%s", demoAuto.mod, DEFAULT_NAME, demoAuto.ext),
			va("%s/demos/%s%s", demoAuto.mod, DEFAULT_NAME_LAST, demoAuto.ext)
		)) {
		Com_Printf(S_COLOR_GREEN "Demo temporarily saved into %s%s\n", DEFAULT_NAME, demoAuto.ext);
	} else if (
		FS_CopyFile(
			va("%s/demos/%s%s", demoAuto.mod, DEFAULT_NAME, demoAuto.ext),
			va("%s/demos/%s%s", demoAuto.mod, demoAuto.demoName, demoAuto.ext), newName, sizeof(newName)
		)) {
		Com_Printf(S_COLOR_GREEN "Demo successfully saved into %s\n", ((Q_stricmp(newName, "")) ? newName : demoAuto.demoName));
	} else {
		Com_Printf(S_COLOR_RED "Demo has failed to save\n");
	}
}
コード例 #6
0
ファイル: sv_ccmds.c プロジェクト: mattx86/aprq2
/*
================
SV_CopySaveGame
================
*/
static void SV_CopySaveGame (const char *src, const char *dst)
{
	char	name[MAX_OSPATH], name2[MAX_OSPATH];
	int		l, len;
	char	*found;

	Com_DPrintf("SV_CopySaveGame(%s, %s)\n", src, dst);

	SV_WipeSavegame(dst);

	// copy the savegame over
	Com_sprintf (name, sizeof(name), "%s/save/%s/server.ssv", FS_Gamedir(), src);
	Com_sprintf (name2, sizeof(name2), "%s/save/%s/server.ssv", FS_Gamedir(), dst);
	FS_CopyFile(name, name2);

	Com_sprintf (name, sizeof(name), "%s/save/%s/game.ssv", FS_Gamedir(), src);
	Com_sprintf (name2, sizeof(name2), "%s/save/%s/game.ssv", FS_Gamedir(), dst);
	FS_CopyFile(name, name2);

	Com_sprintf (name, sizeof(name), "%s/save/%s/", FS_Gamedir(), src);
	len = strlen(name);
	Com_sprintf (name, sizeof(name), "%s/save/%s/*.sav", FS_Gamedir(), src);
	found = Sys_FindFirst(name, 0, 0 );
	while (found)
	{
		strcpy (name+len, found+len);

		Com_sprintf (name2, sizeof(name2), "%s/save/%s/%s", FS_Gamedir(), dst, found+len);
		FS_CopyFile(name, name2);

		// change sav to sv2
		l = strlen(name);
		strcpy (name+l-3, "sv2");
		l = strlen(name2);
		strcpy (name2+l-3, "sv2");
		FS_CopyFile(name, name2);

		found = Sys_FindNext( 0, 0 );
	}
	Sys_FindClose ();
}
コード例 #7
0
void PbSvMakeHomepathCopy(const char *modulename, char *homepath)
{
	char dstpath[512];
	char srcpath[512];
	
	Q_strncpyz(srcpath, pbsv.pbPath, sizeof( srcpath ) );
	Q_strcat( dstpath, sizeof(dstpath), modulename );
	/* File exists ? */
	if ( FS_FileExistsOSPath( dstpath ) == qtrue )
	{
		return;
	}
	/* Does not exist! Copy it from basepath */
	Q_strncpyz(srcpath, homepath, sizeof( srcpath ) );
	Q_strcat( srcpath, sizeof(srcpath), modulename );	
	Q_strcat( dstpath, sizeof(dstpath), modulename );
	FS_CopyFile( srcpath, dstpath );
}
コード例 #8
0
ファイル: unix_main.c プロジェクト: chegestar/omni-bot
/*
=================
Try_CopyDLLForMod
little utility function for media-only mods
tries to copy a reference DLL to the mod's fs_homepath
return false if failed, or if we are not in a mod situation
returns true if successful, *p_fn is set to the correct path
this is used when we are loading a mod and realize we don't have the DLL in the standard path
=================
*/
qboolean CopyDLLForMod( char **p_fn, const char* gamedir, const char *pwdpath, const char  *homepath, const char *basepath, const char *fname ) {
	char *fn = *p_fn;

	// this may be a media only mod, so next we need to search in the basegame
	if ( strlen( gamedir ) && Q_stricmp( gamedir, BASEGAME ) ) {
		// walk for a base file
		// NOTE TTimo: we don't attempt to validate version-wise, it could be a problem
		// (acceptable tradeoff I say, should not cause major issues)
#ifndef NDEBUG
		fn = FS_BuildOSPath( pwdpath, BASEGAME, fname );
		if ( access( fn, R_OK ) == -1 ) {
#endif
		fn = FS_BuildOSPath( homepath, BASEGAME, fname );
		if ( access( fn, R_OK ) == -1 ) {
			fn = FS_BuildOSPath( basepath, BASEGAME, fname );
			if ( access( fn, R_OK ) == -1 ) {
				return qfalse; // this one is hopeless
			}
		}
#ifndef NDEBUG
	}
#endif
		// basefile found, we copy to homepath in all cases
		// fortunately FS_BuildOSPath does a flip flop, we have 'from path' in fn and 'to path' in *p_fn
		*p_fn = FS_BuildOSPath( homepath, gamedir, fname );
		// copy to destination
		FS_CopyFile( fn, *p_fn );
		if ( access( *p_fn, R_OK ) == -1 ) { // could do with FS_CopyFile returning a boolean actually
			Com_DPrintf( "Copy operation failed\n" );
			return qfalse;
		}
		return qtrue;
	} else
	{
		return qfalse;
	}
}
コード例 #9
0
ファイル: download.c プロジェクト: boutetnico/etlegacy
/*
==================
Com_WWWDownload
==================
*/
void Com_WWWDownload(void)
{
	char            *to_ospath;
	dlStatus_t      ret;
	static qboolean bAbort = qfalse;

	if (dld.bWWWDlAborting)
	{
		if (!bAbort)
		{
			Com_DPrintf("Com_WWWDownload: WWWDlAborting\n");
			bAbort = qtrue;
		}
		return;
	}
	if (bAbort)
	{
		Com_DPrintf("Com_WWWDownload: WWWDlAborting done\n");
		bAbort = qfalse;
	}

	ret = DL_DownloadLoop();

	if (ret == DL_CONTINUE)
	{
		return;
	}

	if (ret == DL_DONE)
	{
		// taken from CL_ParseDownload
		// we work with OS paths
		dld.download                     = 0;
		to_ospath                        = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), dld.originalDownloadName, "");
		to_ospath[strlen(to_ospath) - 1] = '\0';
		if (rename(dld.downloadTempName, to_ospath))
		{
			FS_CopyFile(dld.downloadTempName, to_ospath);
			remove(dld.downloadTempName);
		}
		*dld.downloadTempName = *dld.downloadName = 0;
		Cvar_Set("cl_downloadName", "");
		if (dld.bWWWDlDisconnected)
		{
			// for an auto-update in disconnected mode, we'll be spawning the setup in CL_DownloadsComplete
			if (!autoupdate.updateStarted && !dld.noReconnect)
			{
				// reconnect to the server, which might send us to a new disconnected download
				Cbuf_ExecuteText(EXEC_APPEND, "reconnect\n");
			}
		}
		else
		{
			Com_AddReliableCommand("wwwdl done");
			// tracking potential web redirects leading us to wrong checksum - only works in connected mode
			if (strlen(dld.redirectedList) + strlen(dld.originalDownloadName) + 1 >= sizeof(dld.redirectedList))
			{
				// just to be safe
				Com_Printf("ERROR: redirectedList overflow (%s)\n", dld.redirectedList);
			}
			else
			{
				strcat(dld.redirectedList, "@");
				strcat(dld.redirectedList, dld.originalDownloadName);
			}
		}
	}
	else
	{
		if (dld.bWWWDlDisconnected)
		{
			// in a connected download, we'd tell the server about failure and wait for a reply
			// but in this case we can't get anything from server
			// if we just reconnect it's likely we'll get the same disconnected download message, and error out again
			// this may happen for a regular dl or an auto update
			const char *error = va("Download failure while getting '%s'\n", dld.downloadName);    // get the msg before clearing structs

			dld.bWWWDlDisconnected = qfalse; // need clearing structs before ERR_DROP, or it goes into endless reload
			Com_ClearStaticDownload();
			Com_Error(ERR_DROP, "%s", error);
		}
		else
		{
			// see CL_ParseDownload, same abort strategy
			Com_Printf("Download failure while getting '%s'\n", dld.downloadName);
			Com_AddReliableCommand("wwwdl fail");
			dld.bWWWDlAborting = qtrue;
		}
		return;
	}

	dld.bWWWDl = qfalse;
	Com_NextDownload();
}