[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36461] trunk/blender/source/blender: remove player runtime writing functions, this is now an addon.

Campbell Barton ideasman42 at gmail.com
Tue May 3 10:45:41 CEST 2011


Revision: 36461
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36461
Author:   campbellbarton
Date:     2011-05-03 08:45:40 +0000 (Tue, 03 May 2011)
Log Message:
-----------
remove player runtime writing functions, this is now an addon.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_path_util.h
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/blenloader/intern/writefile.c

Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h	2011-05-03 08:21:11 UTC (rev 36460)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h	2011-05-03 08:45:40 UTC (rev 36461)
@@ -197,7 +197,6 @@
 	 */
 void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name);
 
-char *get_install_dir(void);
 	/**
 	 * Gets the temp directory when blender first runs.
 	 * If the default path is not found, use try $TEMP

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c	2011-05-03 08:21:11 UTC (rev 36460)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c	2011-05-03 08:45:40 UTC (rev 36461)
@@ -1802,26 +1802,6 @@
 	}
 }
 
-char *get_install_dir(void) {
-	char *tmpname = BLI_strdup(bprogname);
-	char *cut;
-
-#ifdef __APPLE__
-	cut = strstr(tmpname, ".app");
-	if (cut) cut[0] = 0;
-#endif
-
-	cut = BLI_last_slash(tmpname);
-
-	if (cut) {
-		cut[0] = 0;
-		return tmpname;
-	} else {
-		MEM_freeN(tmpname);
-		return NULL;
-	}
-}
-
 #ifdef WITH_ICONV
 
 void BLI_string_to_utf8(char *original, char *utf_8, const char *code)

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2011-05-03 08:21:11 UTC (rev 36460)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2011-05-03 08:45:40 UTC (rev 36461)
@@ -2618,187 +2618,3 @@
 	if(err==0) return 1;
 	return 0;
 }
-
-
-	/* Runtime writing */
-
-static char *get_runtime_path(char *exename) {
-	char *installpath= get_install_dir();
-
-	if (!installpath) {
-		return NULL;
-	}
-	else {
-		char *path= BLI_sprintfN("%s%c%s", installpath, SEP, exename);
-
-		if (path == NULL) {
-			MEM_freeN(installpath);
-			return NULL;
-		}
-
-		MEM_freeN(installpath);
-
-		return path;
-	}
-}
-
-#ifdef __APPLE__
-
-static int recursive_copy_runtime(const char *outname, char *exename, ReportList *reports)
-{
-	char *runtime = get_runtime_path(exename);
-	char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
-	int progfd = -1, error= 0;
-
-	if (!runtime) {
-		BKE_report(reports, RPT_ERROR, "Unable to find runtime");
-		error= 1;
-		goto cleanup;
-	}
-	//printf("runtimepath %s\n", runtime);
-		
-	progfd= open(runtime, O_BINARY|O_RDONLY, 0);
-	if (progfd==-1) {
-		BKE_report(reports, RPT_ERROR, "Unable to find runtime");
-		error= 1;
-		goto cleanup;
-	}
-
-	sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
-	//printf("command %s\n", command);
-	if (system(command) == -1) {
-		BKE_report(reports, RPT_ERROR, "Couldn't copy runtime");
-		error= 1;
-	}
-
-cleanup:
-	if (progfd!=-1)
-		close(progfd);
-	if (runtime)
-		MEM_freeN(runtime);
-
-	return !error;
-}
-
-int BLO_write_runtime(Main *mainvar, const char *file, char *exename, ReportList *reports) 
-{
-	char gamename[FILE_MAXDIR+FILE_MAXFILE];
-	int outfd = -1, error= 0;
-
-	// remove existing file / bundle
-	//printf("Delete file %s\n", file);
-	BLI_delete(file, 0, TRUE);
-
-	if (!recursive_copy_runtime(file, exename, reports)) {
-		error= 1;
-		goto cleanup;
-	}
-
-	BLI_snprintf(gamename, sizeof(gamename), "%s/Contents/Resources/game.blend", file);
-	//printf("gamename %s\n", gamename);
-	outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
-	if (outfd != -1) {
-
-		write_file_handle(mainvar, outfd, NULL,NULL, 0, G.fileflags, NULL);
-
-		if (write(outfd, " ", 1) != 1) {
-			BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
-			error= 1;
-			goto cleanup;
-		}
-	} else {
-		BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
-		error= 1;
-	}
-
-cleanup:
-	if (outfd!=-1)
-		close(outfd);
-
-	BKE_reports_prepend(reports, "Unable to make runtime: ");
-	return !error;
-}
-
-#else /* !__APPLE__ */
-
-static int handle_append_runtime(int handle, char *exename, ReportList *reports)
-{
-	char *runtime= get_runtime_path(exename);
-	unsigned char buf[1024];
-	int count, progfd= -1, error= 0;
-
-	if (!BLI_exists(runtime)) {
-		BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
-		error= 1;
-		goto cleanup;
-	}
-
-	progfd= open(runtime, O_BINARY|O_RDONLY, 0);
-	if (progfd==-1) {
-		BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
-		error= 1;
-		goto cleanup;
-	}
-
-	while ((count= read(progfd, buf, sizeof(buf)))>0) {
-		if (write(handle, buf, count)!=count) {
-			BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
-			error= 1;
-			goto cleanup;
-		}
-	}
-
-cleanup:
-	if (progfd!=-1)
-		close(progfd);
-	if (runtime)
-		MEM_freeN(runtime);
-
-	return !error;
-}
-
-static int handle_write_msb_int(int handle, int i) 
-{
-	unsigned char buf[4];
-	buf[0]= (i>>24)&0xFF;
-	buf[1]= (i>>16)&0xFF;
-	buf[2]= (i>>8)&0xFF;
-	buf[3]= (i>>0)&0xFF;
-
-	return (write(handle, buf, 4)==4);
-}
-
-int BLO_write_runtime(Main *mainvar, const char *file, char *exename, ReportList *reports)
-{
-	int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
-	int datastart, error= 0;
-
-	if (!outfd) {
-		BKE_report(reports, RPT_ERROR, "Unable to open output file.");
-		error= 1;
-		goto cleanup;
-	}
-	if (!handle_append_runtime(outfd, exename, reports)) {
-		error= 1;
-		goto cleanup;
-	}
-
-	datastart= lseek(outfd, 0, SEEK_CUR);
-
-	write_file_handle(mainvar, outfd, NULL,NULL, 0, G.fileflags, NULL);
-
-	if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
-		BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
-		error= 1;
-		goto cleanup;
-	}
-
-cleanup:
-	if (outfd!=-1)
-		close(outfd);
-
-	BKE_reports_prepend(reports, "Unable to make runtime: ");
-	return !error;
-}
-
-#endif /* !__APPLE__ */




More information about the Bf-blender-cvs mailing list