remove player runtime writing functions, this is now an addon.

This commit is contained in:
Campbell Barton 2011-05-03 08:45:40 +00:00
parent cd2728ea0d
commit 0a2a138d86
3 changed files with 0 additions and 205 deletions

View File

@ -197,7 +197,6 @@ void BLI_char_switch(char *string, char from, char to);
*/
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

View File

@ -1802,26 +1802,6 @@ void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
}
}
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)

View File

@ -2618,187 +2618,3 @@ int BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int wr
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__ */