forked from bartvdbraak/blender
2.5: Change blenloader module to use the Report system for reporting errors.
This commit is contained in:
parent
ea81c58429
commit
d9de6fca6c
@ -48,7 +48,8 @@ typedef enum ReportType {
|
|||||||
|
|
||||||
enum ReportListFlags {
|
enum ReportListFlags {
|
||||||
RPT_PRINT = 1,
|
RPT_PRINT = 1,
|
||||||
RPT_STORE = 2
|
RPT_STORE = 2,
|
||||||
|
RPT_HAS_ERROR = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Report {
|
typedef struct Report {
|
||||||
@ -60,20 +61,24 @@ typedef struct Report {
|
|||||||
|
|
||||||
typedef struct ReportList {
|
typedef struct ReportList {
|
||||||
ListBase list;
|
ListBase list;
|
||||||
ReportType level;
|
ReportType printlevel;
|
||||||
int flags;
|
ReportType storelevel;
|
||||||
|
int flag;
|
||||||
} ReportList;
|
} ReportList;
|
||||||
|
|
||||||
void BKE_report_list_init(ReportList *reports, int flag);
|
void BKE_reports_init(ReportList *reports, int flag);
|
||||||
void BKE_report_list_clear(ReportList *reports);
|
void BKE_reports_clear(ReportList *reports);
|
||||||
|
|
||||||
void BKE_report(ReportList *reports, ReportType type, const char *message);
|
void BKE_report(ReportList *reports, ReportType type, const char *message);
|
||||||
void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
|
void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
|
||||||
|
|
||||||
ReportType BKE_report_level(ReportList *reports);
|
ReportType BKE_report_print_level(ReportList *reports);
|
||||||
void BKE_report_level_set(ReportList *reports, ReportType level);
|
void BKE_report_print_level_set(ReportList *reports, ReportType level);
|
||||||
|
|
||||||
int BKE_report_has_error(ReportList *reports);
|
ReportType BKE_report_store_level(ReportList *reports);
|
||||||
|
void BKE_report_store_level_set(ReportList *reports, ReportType level);
|
||||||
|
|
||||||
|
void BKE_reports_print(ReportList *reports, ReportType level);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
#include "BKE_object.h"
|
#include "BKE_object.h"
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
#include "BKE_screen.h"
|
#include "BKE_screen.h"
|
||||||
#include "BKE_sound.h"
|
#include "BKE_sound.h"
|
||||||
@ -435,11 +436,13 @@ static void handle_subversion_warning(Main *main)
|
|||||||
|
|
||||||
int BKE_read_file(bContext *C, char *dir, void *unused)
|
int BKE_read_file(bContext *C, char *dir, void *unused)
|
||||||
{
|
{
|
||||||
BlendReadError bre;
|
ReportList reports;
|
||||||
BlendFileData *bfd;
|
BlendFileData *bfd;
|
||||||
int retval= 1;
|
int retval= 1;
|
||||||
|
|
||||||
bfd= BLO_read_from_file(dir, &bre);
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
|
||||||
|
bfd= BLO_read_from_file(dir, &reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
if(bfd->user) retval= 2;
|
if(bfd->user) retval= 2;
|
||||||
|
|
||||||
@ -450,38 +453,48 @@ int BKE_read_file(bContext *C, char *dir, void *unused)
|
|||||||
else {
|
else {
|
||||||
// XXX error("Loading %s failed: %s", dir, BLO_bre_as_string(bre));
|
// XXX error("Loading %s failed: %s", dir, BLO_bre_as_string(bre));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
return (bfd?retval:0);
|
return (bfd?retval:0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, void *unused)
|
int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, void *unused)
|
||||||
{
|
{
|
||||||
BlendReadError bre;
|
ReportList reports;
|
||||||
BlendFileData *bfd;
|
BlendFileData *bfd;
|
||||||
|
|
||||||
bfd= BLO_read_from_memory(filebuf, filelength, &bre);
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
|
||||||
|
bfd= BLO_read_from_memory(filebuf, filelength, &reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
setup_app_data(C, bfd, "<memory2>");
|
setup_app_data(C, bfd, "<memory2>");
|
||||||
} else {
|
} else {
|
||||||
// XXX error("Loading failed: %s", BLO_bre_as_string(bre));
|
// XXX error("Loading failed: %s", BLO_bre_as_string(bre));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
return (bfd?1:0);
|
return (bfd?1:0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* memfile is the undo buffer */
|
/* memfile is the undo buffer */
|
||||||
int BKE_read_file_from_memfile(bContext *C, MemFile *memfile)
|
int BKE_read_file_from_memfile(bContext *C, MemFile *memfile)
|
||||||
{
|
{
|
||||||
BlendReadError bre;
|
ReportList reports;
|
||||||
BlendFileData *bfd;
|
BlendFileData *bfd;
|
||||||
|
|
||||||
bfd= BLO_read_from_memfile(G.sce, memfile, &bre);
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
|
||||||
|
bfd= BLO_read_from_memfile(G.sce, memfile, &reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
setup_app_data(C, bfd, "<memory1>");
|
setup_app_data(C, bfd, "<memory1>");
|
||||||
} else {
|
} else {
|
||||||
// XXX error("Loading failed: %s", BLO_bre_as_string(bre));
|
// XXX error("Loading failed: %s", BLO_bre_as_string(bre));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
return (bfd?1:0);
|
return (bfd?1:0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,8 +581,9 @@ void BKE_write_undo(bContext *C, char *name)
|
|||||||
|
|
||||||
/* disk save version */
|
/* disk save version */
|
||||||
if(UNDO_DISK) {
|
if(UNDO_DISK) {
|
||||||
|
ReportList reports;
|
||||||
static int counter= 0;
|
static int counter= 0;
|
||||||
char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
|
char tstr[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
char numstr[32];
|
char numstr[32];
|
||||||
|
|
||||||
/* calculate current filename */
|
/* calculate current filename */
|
||||||
@ -579,18 +593,22 @@ void BKE_write_undo(bContext *C, char *name)
|
|||||||
sprintf(numstr, "%d.blend", counter);
|
sprintf(numstr, "%d.blend", counter);
|
||||||
BLI_make_file_string("/", tstr, btempdir, numstr);
|
BLI_make_file_string("/", tstr, btempdir, numstr);
|
||||||
|
|
||||||
success= BLO_write_file(C, tstr, G.fileflags, &err);
|
BKE_reports_init(&reports, 0);
|
||||||
|
success= BLO_write_file(C, tstr, G.fileflags, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
strcpy(curundo->str, tstr);
|
strcpy(curundo->str, tstr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ReportList reports;
|
||||||
MemFile *prevfile=NULL;
|
MemFile *prevfile=NULL;
|
||||||
char *err;
|
|
||||||
|
|
||||||
if(curundo->prev) prevfile= &(curundo->prev->memfile);
|
if(curundo->prev) prevfile= &(curundo->prev->memfile);
|
||||||
|
|
||||||
memused= MEM_get_memory_in_use();
|
memused= MEM_get_memory_in_use();
|
||||||
success= BLO_write_file_mem(C, prevfile, &curundo->memfile, G.fileflags, &err);
|
BKE_reports_init(&reports, 0);
|
||||||
|
success= BLO_write_file_mem(C, prevfile, &curundo->memfile, G.fileflags, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
curundo->undosize= MEM_get_memory_in_use() - memused;
|
curundo->undosize= MEM_get_memory_in_use() - memused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,15 +57,16 @@ static char *report_type_str(int type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_report_list_init(ReportList *reports, int flags)
|
void BKE_reports_init(ReportList *reports, int flag)
|
||||||
{
|
{
|
||||||
memset(reports, 0, sizeof(ReportList));
|
memset(reports, 0, sizeof(ReportList));
|
||||||
|
|
||||||
reports->level= RPT_WARNING;
|
reports->storelevel= RPT_WARNING;
|
||||||
reports->flags= flags;
|
reports->printlevel= RPT_WARNING;
|
||||||
|
reports->flag= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_report_list_clear(ReportList *reports)
|
void BKE_reports_clear(ReportList *reports)
|
||||||
{
|
{
|
||||||
Report *report;
|
Report *report;
|
||||||
|
|
||||||
@ -80,15 +81,18 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
|
|||||||
Report *report;
|
Report *report;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(!reports || type < reports->level)
|
if(!reports)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(type >= RPT_ERROR)
|
||||||
|
reports->flag |= RPT_HAS_ERROR;
|
||||||
|
|
||||||
if(reports->flags & RPT_PRINT) {
|
if((reports->flag & RPT_PRINT) && (type >= reports->printlevel)) {
|
||||||
printf("%s: %s\n", report_type_str(type), message);
|
printf("%s: %s\n", report_type_str(type), message);
|
||||||
fflush(stdout); /* this ensures the message is printed before a crash */
|
fflush(stdout); /* this ensures the message is printed before a crash */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reports->flags & RPT_STORE) {
|
if((reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
|
||||||
report= MEM_callocN(sizeof(Report), "Report");
|
report= MEM_callocN(sizeof(Report), "Report");
|
||||||
report->type= type;
|
report->type= type;
|
||||||
report->typestr= report_type_str(type);
|
report->typestr= report_type_str(type);
|
||||||
@ -108,17 +112,20 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
|
|||||||
char *message;
|
char *message;
|
||||||
int len= 256, maxlen= 65536, retval;
|
int len= 256, maxlen= 65536, retval;
|
||||||
|
|
||||||
if(!reports || type < reports->level)
|
if(!reports)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(reports->flags & RPT_PRINT) {
|
if(type >= RPT_ERROR)
|
||||||
|
reports->flag |= RPT_HAS_ERROR;
|
||||||
|
|
||||||
|
if((reports->flag & RPT_PRINT) && (type >= reports->printlevel)) {
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vprintf(format, args);
|
vprintf(format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fflush(stdout); /* this ensures the message is printed before a crash */
|
fflush(stdout); /* this ensures the message is printed before a crash */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reports->flags & RPT_STORE) {
|
if((reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
|
||||||
while(1) {
|
while(1) {
|
||||||
message= MEM_callocN(sizeof(char)*len+1, "ReportMessage");
|
message= MEM_callocN(sizeof(char)*len+1, "ReportMessage");
|
||||||
|
|
||||||
@ -160,27 +167,37 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportType BKE_report_level(ReportList *reports)
|
ReportType BKE_report_print_level(ReportList *reports)
|
||||||
{
|
{
|
||||||
return reports->level;
|
return reports->printlevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_report_level_set(ReportList *reports, ReportType level)
|
void BKE_report_print_level_set(ReportList *reports, ReportType level)
|
||||||
{
|
{
|
||||||
reports->level= level;
|
reports->printlevel= level;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BKE_report_has_error(ReportList *reports)
|
ReportType BKE_report_store_level(ReportList *reports)
|
||||||
|
{
|
||||||
|
return reports->storelevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_report_store_level_set(ReportList *reports, ReportType level)
|
||||||
|
{
|
||||||
|
reports->storelevel= level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_reports_print(ReportList *reports, ReportType level)
|
||||||
{
|
{
|
||||||
Report *report;
|
Report *report;
|
||||||
|
|
||||||
if(!reports)
|
if(!reports)
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
for(report=reports->list.first; report; report=report->next)
|
|
||||||
if(report->type >= RPT_ERROR)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
for(report=reports->list.first; report; report=report->next)
|
||||||
|
if(report->type >= level)
|
||||||
|
printf("%s: %s\n", report->typestr, report->message);
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,16 +34,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct SpaceFile;
|
struct bScreen;
|
||||||
struct SpaceImaSel;
|
struct direntry;
|
||||||
struct FileList;
|
struct FileList;
|
||||||
struct LinkNode;
|
struct LinkNode;
|
||||||
struct Main;
|
struct Main;
|
||||||
struct UserDef;
|
|
||||||
struct bScreen;
|
|
||||||
struct Scene;
|
|
||||||
struct MemFile;
|
struct MemFile;
|
||||||
struct direntry;
|
struct ReportList;
|
||||||
|
struct Scene;
|
||||||
|
struct SpaceFile;
|
||||||
|
struct SpaceImaSel;
|
||||||
|
struct UserDef;
|
||||||
|
|
||||||
typedef struct BlendHandle BlendHandle;
|
typedef struct BlendHandle BlendHandle;
|
||||||
|
|
||||||
@ -53,29 +54,6 @@ typedef enum BlenFileType {
|
|||||||
BLENFILETYPE_RUNTIME= 3
|
BLENFILETYPE_RUNTIME= 3
|
||||||
} BlenFileType;
|
} BlenFileType;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
BRE_NONE,
|
|
||||||
|
|
||||||
BRE_UNABLE_TO_OPEN,
|
|
||||||
BRE_UNABLE_TO_READ,
|
|
||||||
|
|
||||||
BRE_OUT_OF_MEMORY,
|
|
||||||
BRE_INTERNAL_ERROR,
|
|
||||||
|
|
||||||
BRE_NOT_A_BLEND,
|
|
||||||
BRE_NOT_A_PUBFILE,
|
|
||||||
BRE_INCOMPLETE,
|
|
||||||
BRE_CORRUPT,
|
|
||||||
|
|
||||||
BRE_TOO_NEW,
|
|
||||||
BRE_NOT_ALLOWED,
|
|
||||||
|
|
||||||
BRE_NO_SCREEN,
|
|
||||||
BRE_NO_SCENE,
|
|
||||||
|
|
||||||
BRE_INVALID
|
|
||||||
} BlendReadError;
|
|
||||||
|
|
||||||
typedef struct BlendFileData {
|
typedef struct BlendFileData {
|
||||||
struct Main* main;
|
struct Main* main;
|
||||||
struct UserDef* user;
|
struct UserDef* user;
|
||||||
@ -93,46 +71,33 @@ typedef struct BlendFileData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a blender file from a pathname. The function
|
* Open a blender file from a pathname. The function
|
||||||
* returns NULL and sets the @a error_r argument if
|
* returns NULL and sets a report in the list if
|
||||||
* it cannot open the file.
|
* it cannot open the file.
|
||||||
*
|
*
|
||||||
* @param file The path of the file to open.
|
* @param file The path of the file to open.
|
||||||
* @param error_r If the return value is NULL, an error
|
* @param reports If the return value is NULL, errors
|
||||||
* code indicating the cause of the failure.
|
* indicating the cause of the failure.
|
||||||
* @return The data of the file.
|
* @return The data of the file.
|
||||||
*/
|
*/
|
||||||
BlendFileData* BLO_read_from_file (char *file, BlendReadError *error_r);
|
BlendFileData* BLO_read_from_file (char *file, struct ReportList *reports);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a blender file from memory. The function
|
* Open a blender file from memory. The function
|
||||||
* returns NULL and sets the @a error_r argument if
|
* returns NULL and sets a report in the list if
|
||||||
* it cannot open the file.
|
* it cannot open the file.
|
||||||
*
|
*
|
||||||
* @param mem The file data.
|
* @param mem The file data.
|
||||||
* @param memsize The length of @a mem.
|
* @param memsize The length of @a mem.
|
||||||
* @param error_r If the return value is NULL, an error
|
* @param reports If the return value is NULL, errors
|
||||||
* code indicating the cause of the failure.
|
* indicating the cause of the failure.
|
||||||
* @return The data of the file.
|
* @return The data of the file.
|
||||||
*/
|
*/
|
||||||
BlendFileData* BLO_read_from_memory(void *mem, int memsize, BlendReadError *error_r);
|
BlendFileData* BLO_read_from_memory(void *mem, int memsize, struct ReportList *reports);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file name is current file, only for retrieving library data */
|
* file name is current file, only for retrieving library data */
|
||||||
|
|
||||||
BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, BlendReadError *error_r);
|
BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, struct ReportList *reports);
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a BlendReadError to a human readable string.
|
|
||||||
* The string is static and does not need to be free'd.
|
|
||||||
*
|
|
||||||
* @param error The error to return a string for.
|
|
||||||
* @return A static human readable string representation
|
|
||||||
* of @a error.
|
|
||||||
*/
|
|
||||||
|
|
||||||
char*
|
|
||||||
BLO_bre_as_string(
|
|
||||||
BlendReadError error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free's a BlendFileData structure and _all_ the
|
* Free's a BlendFileData structure and _all_ the
|
||||||
@ -239,7 +204,7 @@ void BLO_library_append_(BlendHandle **libfiledata, struct direntry* filelist, i
|
|||||||
char *dir, char* file, short flag, int idcode, struct Scene *scene);
|
char *dir, char* file, short flag, int idcode, struct Scene *scene);
|
||||||
void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Scene *scene);
|
void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Scene *scene);
|
||||||
|
|
||||||
BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, BlendReadError *error_r);
|
BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,12 @@
|
|||||||
|
|
||||||
struct MemFile;
|
struct MemFile;
|
||||||
struct bContext;
|
struct bContext;
|
||||||
|
struct ReportList;
|
||||||
|
|
||||||
extern int BLO_write_file(struct bContext *C, char *dir, int write_flags, char **error_r);
|
extern int BLO_write_file(struct bContext *C, char *dir, int write_flags, struct ReportList *reports);
|
||||||
extern int BLO_write_file_mem(struct bContext *C, struct MemFile *compare, struct MemFile *current,
|
extern int BLO_write_file_mem(struct bContext *C, struct MemFile *compare, struct MemFile *current,
|
||||||
int write_flags, char **error_r);
|
int write_flags, struct ReportList *reports);
|
||||||
extern void BLO_write_runtime(struct bContext *C, char *file, char *exename);
|
extern int BLO_write_runtime(struct bContext *C, char *file, char *exename, struct ReportList *reports);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_library.h" // for free_main
|
#include "BKE_library.h" // for free_main
|
||||||
|
#include "BKE_report.h"
|
||||||
|
|
||||||
#include "BLO_readfile.h"
|
#include "BLO_readfile.h"
|
||||||
#include "BLO_undofile.h"
|
#include "BLO_undofile.h"
|
||||||
@ -166,9 +167,14 @@ int BLO_idcode_from_name(char *name)
|
|||||||
|
|
||||||
BlendHandle *BLO_blendhandle_from_file(char *file)
|
BlendHandle *BLO_blendhandle_from_file(char *file)
|
||||||
{
|
{
|
||||||
BlendReadError err;
|
ReportList reports;
|
||||||
|
BlendHandle *bh;
|
||||||
|
|
||||||
return (BlendHandle*) blo_openblenderfile(file, &err);
|
BKE_reports_init(&reports, 0);
|
||||||
|
bh= (BlendHandle*)blo_openblenderfile(file, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
|
return bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
|
void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
|
||||||
@ -318,14 +324,14 @@ void BLO_blendhandle_close(BlendHandle *bh) {
|
|||||||
|
|
||||||
/**********/
|
/**********/
|
||||||
|
|
||||||
BlendFileData *BLO_read_from_file(char *file, BlendReadError *error_r)
|
BlendFileData *BLO_read_from_file(char *file, ReportList *reports)
|
||||||
{
|
{
|
||||||
BlendFileData *bfd = NULL;
|
BlendFileData *bfd = NULL;
|
||||||
FileData *fd;
|
FileData *fd;
|
||||||
|
|
||||||
fd = blo_openblenderfile(file, error_r);
|
fd = blo_openblenderfile(file, reports);
|
||||||
if (fd) {
|
if (fd) {
|
||||||
bfd= blo_read_file_internal(fd, error_r);
|
bfd= blo_read_file_internal(fd, reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
bfd->type= BLENFILETYPE_BLEND;
|
bfd->type= BLENFILETYPE_BLEND;
|
||||||
strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
|
strncpy(bfd->main->name, file, sizeof(bfd->main->name)-1);
|
||||||
@ -336,14 +342,14 @@ BlendFileData *BLO_read_from_file(char *file, BlendReadError *error_r)
|
|||||||
return bfd;
|
return bfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendFileData *BLO_read_from_memory(void *mem, int memsize, BlendReadError *error_r)
|
BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports)
|
||||||
{
|
{
|
||||||
BlendFileData *bfd = NULL;
|
BlendFileData *bfd = NULL;
|
||||||
FileData *fd;
|
FileData *fd;
|
||||||
|
|
||||||
fd = blo_openblendermemory(mem, memsize, error_r);
|
fd = blo_openblendermemory(mem, memsize, reports);
|
||||||
if (fd) {
|
if (fd) {
|
||||||
bfd= blo_read_file_internal(fd, error_r);
|
bfd= blo_read_file_internal(fd, reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
bfd->type= BLENFILETYPE_BLEND;
|
bfd->type= BLENFILETYPE_BLEND;
|
||||||
strcpy(bfd->main->name, "");
|
strcpy(bfd->main->name, "");
|
||||||
@ -354,13 +360,13 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, BlendReadError *erro
|
|||||||
return bfd;
|
return bfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendFileData *BLO_read_from_memfile(const char *filename, MemFile *memfile, BlendReadError *error_r)
|
BlendFileData *BLO_read_from_memfile(const char *filename, MemFile *memfile, ReportList *reports)
|
||||||
{
|
{
|
||||||
BlendFileData *bfd = NULL;
|
BlendFileData *bfd = NULL;
|
||||||
FileData *fd;
|
FileData *fd;
|
||||||
ListBase mainlist;
|
ListBase mainlist;
|
||||||
|
|
||||||
fd = blo_openblendermemfile(memfile, error_r);
|
fd = blo_openblendermemfile(memfile, reports);
|
||||||
if (fd) {
|
if (fd) {
|
||||||
strcpy(fd->filename, filename);
|
strcpy(fd->filename, filename);
|
||||||
|
|
||||||
@ -375,7 +381,7 @@ BlendFileData *BLO_read_from_memfile(const char *filename, MemFile *memfile, Ble
|
|||||||
/* makes lookup of existing images in G.main */
|
/* makes lookup of existing images in G.main */
|
||||||
blo_make_image_pointer_map(fd);
|
blo_make_image_pointer_map(fd);
|
||||||
|
|
||||||
bfd= blo_read_file_internal(fd, error_r);
|
bfd= blo_read_file_internal(fd, reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
bfd->type= BLENFILETYPE_BLEND;
|
bfd->type= BLENFILETYPE_BLEND;
|
||||||
strcpy(bfd->main->name, "");
|
strcpy(bfd->main->name, "");
|
||||||
@ -416,43 +422,3 @@ void BLO_blendfiledata_free(BlendFileData *bfd)
|
|||||||
MEM_freeN(bfd);
|
MEM_freeN(bfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *BLO_bre_as_string(BlendReadError error)
|
|
||||||
{
|
|
||||||
switch (error) {
|
|
||||||
case BRE_NONE:
|
|
||||||
return "No error";
|
|
||||||
|
|
||||||
case BRE_UNABLE_TO_OPEN:
|
|
||||||
return "Unable to open";
|
|
||||||
case BRE_UNABLE_TO_READ:
|
|
||||||
return "Unable to read";
|
|
||||||
|
|
||||||
case BRE_OUT_OF_MEMORY:
|
|
||||||
return "Out of memory";
|
|
||||||
case BRE_INTERNAL_ERROR:
|
|
||||||
return "<internal error>";
|
|
||||||
|
|
||||||
case BRE_NOT_A_BLEND:
|
|
||||||
return "File is not a Blender file";
|
|
||||||
case BRE_NOT_A_PUBFILE:
|
|
||||||
return "File is not a compressed, locked or signed Blender file";
|
|
||||||
case BRE_INCOMPLETE:
|
|
||||||
return "File incomplete";
|
|
||||||
case BRE_CORRUPT:
|
|
||||||
return "File corrupt";
|
|
||||||
|
|
||||||
case BRE_TOO_NEW:
|
|
||||||
return "File needs newer Blender version, please upgrade";
|
|
||||||
case BRE_NOT_ALLOWED:
|
|
||||||
return "File is locked";
|
|
||||||
|
|
||||||
case BRE_NO_SCREEN:
|
|
||||||
return "File has no screen";
|
|
||||||
case BRE_NO_SCENE:
|
|
||||||
return "File has no scene";
|
|
||||||
|
|
||||||
default:
|
|
||||||
case BRE_INVALID:
|
|
||||||
return "<invalid read error>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
#include "BKE_particle.h"
|
#include "BKE_particle.h"
|
||||||
#include "BKE_pointcache.h"
|
#include "BKE_pointcache.h"
|
||||||
#include "BKE_property.h" // for get_ob_property
|
#include "BKE_property.h" // for get_ob_property
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "BKE_sca.h" // for init_actuator
|
#include "BKE_sca.h" // for init_actuator
|
||||||
#include "BKE_scene.h"
|
#include "BKE_scene.h"
|
||||||
#include "BKE_softbody.h" // sbNew()
|
#include "BKE_softbody.h" // sbNew()
|
||||||
@ -925,19 +926,19 @@ static FileData *filedata_new(void)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FileData *blo_decode_and_check(FileData *fd, BlendReadError *error_r)
|
static FileData *blo_decode_and_check(FileData *fd, ReportList *reports)
|
||||||
{
|
{
|
||||||
decode_blender_header(fd);
|
decode_blender_header(fd);
|
||||||
|
|
||||||
if (fd->flags & FD_FLAGS_FILE_OK) {
|
if (fd->flags & FD_FLAGS_FILE_OK) {
|
||||||
if (!read_file_dna(fd)) {
|
if (!read_file_dna(fd)) {
|
||||||
*error_r = BRE_INCOMPLETE;
|
BKE_report(reports, RPT_ERROR, "File incomplete");
|
||||||
blo_freefiledata(fd);
|
blo_freefiledata(fd);
|
||||||
fd= NULL;
|
fd= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*error_r = BRE_NOT_A_BLEND;
|
BKE_report(reports, RPT_ERROR, "File is not a Blender file");
|
||||||
blo_freefiledata(fd);
|
blo_freefiledata(fd);
|
||||||
fd= NULL;
|
fd= NULL;
|
||||||
}
|
}
|
||||||
@ -947,14 +948,14 @@ static FileData *blo_decode_and_check(FileData *fd, BlendReadError *error_r)
|
|||||||
|
|
||||||
/* cannot be called with relative paths anymore! */
|
/* cannot be called with relative paths anymore! */
|
||||||
/* on each new library added, it now checks for the current FileData and expands relativeness */
|
/* on each new library added, it now checks for the current FileData and expands relativeness */
|
||||||
FileData *blo_openblenderfile(char *name, BlendReadError *error_r)
|
FileData *blo_openblenderfile(char *name, ReportList *reports)
|
||||||
{
|
{
|
||||||
gzFile gzfile;
|
gzFile gzfile;
|
||||||
|
|
||||||
gzfile= gzopen(name, "rb");
|
gzfile= gzopen(name, "rb");
|
||||||
|
|
||||||
if (NULL == gzfile) {
|
if (NULL == gzfile) {
|
||||||
*error_r = BRE_UNABLE_TO_OPEN;
|
BKE_report(reports, RPT_ERROR, "Unable to open");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
FileData *fd = filedata_new();
|
FileData *fd = filedata_new();
|
||||||
@ -964,14 +965,14 @@ FileData *blo_openblenderfile(char *name, BlendReadError *error_r)
|
|||||||
/* needed for library_append and read_libraries */
|
/* needed for library_append and read_libraries */
|
||||||
BLI_strncpy(fd->filename, name, sizeof(fd->filename));
|
BLI_strncpy(fd->filename, name, sizeof(fd->filename));
|
||||||
|
|
||||||
return blo_decode_and_check(fd, error_r);
|
return blo_decode_and_check(fd, reports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileData *blo_openblendermemory(void *mem, int memsize, BlendReadError *error_r)
|
FileData *blo_openblendermemory(void *mem, int memsize, ReportList *reports)
|
||||||
{
|
{
|
||||||
if (!mem || memsize<SIZEOFBLENDERHEADER) {
|
if (!mem || memsize<SIZEOFBLENDERHEADER) {
|
||||||
*error_r = mem?BRE_UNABLE_TO_READ:BRE_UNABLE_TO_OPEN;
|
BKE_report(reports, RPT_ERROR, (mem)? "Unable to read": "Unable to open");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
FileData *fd= filedata_new();
|
FileData *fd= filedata_new();
|
||||||
@ -980,14 +981,14 @@ FileData *blo_openblendermemory(void *mem, int memsize, BlendReadError *error_r)
|
|||||||
fd->read= fd_read_from_memory;
|
fd->read= fd_read_from_memory;
|
||||||
fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
|
fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
|
||||||
|
|
||||||
return blo_decode_and_check(fd, error_r);
|
return blo_decode_and_check(fd, reports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileData *blo_openblendermemfile(MemFile *memfile, BlendReadError *error_r)
|
FileData *blo_openblendermemfile(MemFile *memfile, ReportList *reports)
|
||||||
{
|
{
|
||||||
if (!memfile) {
|
if (!memfile) {
|
||||||
*error_r = BRE_UNABLE_TO_OPEN;
|
BKE_report(reports, RPT_ERROR, "Unable to open");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
FileData *fd= filedata_new();
|
FileData *fd= filedata_new();
|
||||||
@ -996,7 +997,7 @@ FileData *blo_openblendermemfile(MemFile *memfile, BlendReadError *error_r)
|
|||||||
fd->read= fd_read_from_memfile;
|
fd->read= fd_read_from_memfile;
|
||||||
fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
|
fd->flags|= FD_FLAGS_NOT_MY_BUFFER;
|
||||||
|
|
||||||
return blo_decode_and_check(fd, error_r);
|
return blo_decode_and_check(fd, reports);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3102,7 +3103,8 @@ static void lib_link_object(FileData *fd, Main *main)
|
|||||||
ob= ob->id.next;
|
ob= ob->id.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(warn); //XXX error("WARNING IN CONSOLE");
|
if(warn) //XXX error("WARNING IN CONSOLE");
|
||||||
|
BKE_report(fd->reports, RPT_WARNING, "Warning in console");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4323,6 +4325,8 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
|
|||||||
MEM_freeN(lib);
|
MEM_freeN(lib);
|
||||||
|
|
||||||
//XXX error("Library had multiple instances, save and reload!");
|
//XXX error("Library had multiple instances, save and reload!");
|
||||||
|
BKE_report(fd->reports, RPT_WARNING, "Library had multiple instances, save and reload!");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8350,7 +8354,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
|
|||||||
return bhead;
|
return bhead;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r)
|
BlendFileData *blo_read_file_internal(FileData *fd, ReportList *reports)
|
||||||
{
|
{
|
||||||
BHead *bhead= blo_firstbhead(fd);
|
BHead *bhead= blo_firstbhead(fd);
|
||||||
BlendFileData *bfd;
|
BlendFileData *bfd;
|
||||||
@ -9538,9 +9542,13 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||||||
FileData *fd= mainptr->curlib->filedata;
|
FileData *fd= mainptr->curlib->filedata;
|
||||||
|
|
||||||
if(fd==NULL) {
|
if(fd==NULL) {
|
||||||
BlendReadError err;
|
ReportList reports;
|
||||||
|
|
||||||
printf("read library: lib %s\n", mainptr->curlib->name);
|
printf("read library: lib %s\n", mainptr->curlib->name);
|
||||||
fd= blo_openblenderfile(mainptr->curlib->filename, &err);
|
BKE_reports_init(&reports, 0);
|
||||||
|
fd= blo_openblenderfile(mainptr->curlib->filename, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
if (fd) {
|
if (fd) {
|
||||||
if (fd->libmap)
|
if (fd->libmap)
|
||||||
oldnewmap_free(fd->libmap);
|
oldnewmap_free(fd->libmap);
|
||||||
@ -9639,7 +9647,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||||||
|
|
||||||
/* reading runtime */
|
/* reading runtime */
|
||||||
|
|
||||||
BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize, BlendReadError *error_r)
|
BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize, ReportList *reports)
|
||||||
{
|
{
|
||||||
BlendFileData *bfd = NULL;
|
BlendFileData *bfd = NULL;
|
||||||
FileData *fd = filedata_new();
|
FileData *fd = filedata_new();
|
||||||
@ -9650,11 +9658,11 @@ BlendFileData *blo_read_blendafterruntime(int file, char *name, int actualsize,
|
|||||||
/* needed for library_append and read_libraries */
|
/* needed for library_append and read_libraries */
|
||||||
BLI_strncpy(fd->filename, name, sizeof(fd->filename));
|
BLI_strncpy(fd->filename, name, sizeof(fd->filename));
|
||||||
|
|
||||||
fd = blo_decode_and_check(fd, error_r);
|
fd = blo_decode_and_check(fd, reports);
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bfd= blo_read_file_internal(fd, error_r);
|
bfd= blo_read_file_internal(fd, reports);
|
||||||
blo_freefiledata(fd);
|
blo_freefiledata(fd);
|
||||||
|
|
||||||
return bfd;
|
return bfd;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
struct OldNewMap;
|
struct OldNewMap;
|
||||||
struct MemFile;
|
struct MemFile;
|
||||||
struct bheadsort;
|
struct bheadsort;
|
||||||
|
struct ReportList;
|
||||||
|
|
||||||
typedef struct FileData {
|
typedef struct FileData {
|
||||||
// linked list of BHeadN's
|
// linked list of BHeadN's
|
||||||
@ -83,7 +84,7 @@ typedef struct FileData {
|
|||||||
* data through streamglue.
|
* data through streamglue.
|
||||||
*/
|
*/
|
||||||
BlendFileData **bfd_r;
|
BlendFileData **bfd_r;
|
||||||
BlendReadError *error_r;
|
struct ReportList *reports;
|
||||||
} FileData;
|
} FileData;
|
||||||
|
|
||||||
typedef struct BHeadN {
|
typedef struct BHeadN {
|
||||||
@ -106,11 +107,11 @@ struct Main;
|
|||||||
void blo_join_main(ListBase *mainlist);
|
void blo_join_main(ListBase *mainlist);
|
||||||
void blo_split_main(ListBase *mainlist, struct Main *main);
|
void blo_split_main(ListBase *mainlist, struct Main *main);
|
||||||
|
|
||||||
BlendFileData *blo_read_file_internal( FileData *fd, BlendReadError *error_r);
|
BlendFileData *blo_read_file_internal( FileData *fd, struct ReportList *reports);
|
||||||
|
|
||||||
FileData *blo_openblenderfile( char *name, BlendReadError *error_r);
|
FileData *blo_openblenderfile( char *name, struct ReportList *reports);
|
||||||
FileData *blo_openblendermemory( void *buffer, int buffersize, BlendReadError *error_r);
|
FileData *blo_openblendermemory( void *buffer, int buffersize, struct ReportList *reports);
|
||||||
FileData *blo_openblendermemfile(struct MemFile *memfile, BlendReadError *error_r);
|
FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports);
|
||||||
|
|
||||||
void blo_clear_proxy_pointers_from_lib(FileData *fd);
|
void blo_clear_proxy_pointers_from_lib(FileData *fd);
|
||||||
void blo_make_image_pointer_map(FileData *fd);
|
void blo_make_image_pointer_map(FileData *fd);
|
||||||
|
@ -155,6 +155,7 @@ Any case: direct data is ALWAYS after the lib block
|
|||||||
#include "BKE_main.h" // G.main
|
#include "BKE_main.h" // G.main
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
#include "BKE_packedFile.h" // for packAll
|
#include "BKE_packedFile.h" // for packAll
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "BKE_screen.h" // for waitcursor
|
#include "BKE_screen.h" // for waitcursor
|
||||||
#include "BKE_sequence.h"
|
#include "BKE_sequence.h"
|
||||||
#include "BKE_sound.h" /* ... and for samples */
|
#include "BKE_sound.h" /* ... and for samples */
|
||||||
@ -2110,7 +2111,7 @@ static int write_file_handle(bContext *C, int handle, MemFile *compare, MemFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return: success (1) */
|
/* return: success (1) */
|
||||||
int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
|
int BLO_write_file(bContext *C, char *dir, int write_flags, ReportList *reports)
|
||||||
{
|
{
|
||||||
char userfilename[FILE_MAXDIR+FILE_MAXFILE];
|
char userfilename[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
char tempname[FILE_MAXDIR+FILE_MAXFILE];
|
char tempname[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
@ -2120,7 +2121,7 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
|
|||||||
|
|
||||||
file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
|
file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
|
||||||
if(file == -1) {
|
if(file == -1) {
|
||||||
*error_r= "Unable to open";
|
BKE_report(reports, RPT_ERROR, "Unable to open file for writing.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2139,23 +2140,23 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
|
|||||||
int ret = BLI_gzip(tempname, dir);
|
int ret = BLI_gzip(tempname, dir);
|
||||||
|
|
||||||
if(-1==ret) {
|
if(-1==ret) {
|
||||||
*error_r= "Failed opening .gz file";
|
BKE_report(reports, RPT_ERROR, "Failed opening .gz file.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(-2==ret) {
|
if(-2==ret) {
|
||||||
*error_r= "Failed opening .blend file for compression";
|
BKE_report(reports, RPT_ERROR, "Failed opening .blend file for compression.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if(BLI_rename(tempname, dir) != 0) {
|
if(BLI_rename(tempname, dir) != 0) {
|
||||||
*error_r= "Can't change old file. File saved with @";
|
BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*error_r= strerror(errno);
|
BKE_report(reports, RPT_ERROR, strerror(errno));
|
||||||
remove(tempname);
|
remove(tempname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -2165,7 +2166,7 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return: success (1) */
|
/* return: success (1) */
|
||||||
int BLO_write_file_mem(bContext *C, MemFile *compare, MemFile *current, int write_flags, char **error_r)
|
int BLO_write_file_mem(bContext *C, MemFile *compare, MemFile *current, int write_flags, ReportList *reports)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -2230,28 +2231,28 @@ static char *get_runtime_path(char *exename) {
|
|||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
static int recursive_copy_runtime(char *outname, char *exename, char **cause_r)
|
static int recursive_copy_runtime(char *outname, char *exename, ReportList *reports)
|
||||||
{
|
{
|
||||||
char *cause = NULL, *runtime = get_runtime_path(exename);
|
char *runtime = get_runtime_path(exename);
|
||||||
char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
|
char command[2 * (FILE_MAXDIR+FILE_MAXFILE) + 32];
|
||||||
int progfd = -1;
|
int progfd = -1;
|
||||||
|
|
||||||
if (!runtime) {
|
if (!runtime) {
|
||||||
cause= "Unable to find runtime";
|
BKE_report(reports, RPT_ERROR, "Unable to find runtime");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
//printf("runtimepath %s\n", runtime);
|
//printf("runtimepath %s\n", runtime);
|
||||||
|
|
||||||
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
|
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
|
||||||
if (progfd==-1) {
|
if (progfd==-1) {
|
||||||
cause= "Unable to find runtime";
|
BKE_report(reports, RPT_ERROR, "Unable to find runtime");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
|
sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname);
|
||||||
//printf("command %s\n", command);
|
//printf("command %s\n", command);
|
||||||
if (system(command) == -1) {
|
if (system(command) == -1) {
|
||||||
cause = "Couldn't copy runtime";
|
BKE_report(reports, RPT_ERROR, "Couldn't copy runtime");
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -2260,24 +2261,19 @@ cleanup:
|
|||||||
if (runtime)
|
if (runtime)
|
||||||
MEM_freeN(runtime);
|
MEM_freeN(runtime);
|
||||||
|
|
||||||
if (cause) {
|
return !(reports->flag & RPT_HAS_ERROR);
|
||||||
*cause_r= cause;
|
|
||||||
return 0;
|
|
||||||
} else
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLO_write_runtime(bContext *C, char *file, char *exename)
|
int BLO_write_runtime(bContext *C, char *file, char *exename, ReportList *reports)
|
||||||
{
|
{
|
||||||
char gamename[FILE_MAXDIR+FILE_MAXFILE];
|
char gamename[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
int outfd = -1;
|
int outfd = -1;
|
||||||
char *cause= NULL;
|
|
||||||
|
|
||||||
// remove existing file / bundle
|
// remove existing file / bundle
|
||||||
//printf("Delete file %s\n", file);
|
//printf("Delete file %s\n", file);
|
||||||
BLI_delete(file, 0, TRUE);
|
BLI_delete(file, 0, TRUE);
|
||||||
|
|
||||||
if (!recursive_copy_runtime(file, exename, &cause))
|
if (!recursive_copy_runtime(file, exename, reports))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
strcpy(gamename, file);
|
strcpy(gamename, file);
|
||||||
@ -2289,43 +2285,43 @@ void BLO_write_runtime(bContext *C, char *file, char *exename)
|
|||||||
write_file_handle(C, outfd, NULL,NULL, 0, G.fileflags);
|
write_file_handle(C, outfd, NULL,NULL, 0, G.fileflags);
|
||||||
|
|
||||||
if (write(outfd, " ", 1) != 1) {
|
if (write(outfd, " ", 1) != 1) {
|
||||||
cause= "Unable to write to output file";
|
BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cause = "Unable to open blenderfile";
|
BKE_report(reports, RPT_ERROR, "Unable to open blenderfile.");
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (outfd!=-1)
|
if (outfd!=-1)
|
||||||
close(outfd);
|
close(outfd);
|
||||||
|
|
||||||
if (cause)
|
//XXX error("Unable to make runtime: %s", cause);
|
||||||
error("Unable to make runtime: %s", cause);
|
return !(reports->flag & RPT_HAS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !__APPLE__ */
|
#else /* !__APPLE__ */
|
||||||
|
|
||||||
static int handle_append_runtime(int handle, char *exename, char **cause_r)
|
static int handle_append_runtime(int handle, char *exename, ReportList *reports)
|
||||||
{
|
{
|
||||||
char *cause= NULL, *runtime= get_runtime_path(exename);
|
char *runtime= get_runtime_path(exename);
|
||||||
unsigned char buf[1024];
|
unsigned char buf[1024];
|
||||||
int count, progfd= -1;
|
int count, progfd= -1;
|
||||||
|
|
||||||
if (!BLI_exists(runtime)) {
|
if (!BLI_exists(runtime)) {
|
||||||
cause= "Unable to find runtime";
|
BKE_report(reports, RPT_ERROR, "Unable to find runtime.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
|
progfd= open(runtime, O_BINARY|O_RDONLY, 0);
|
||||||
if (progfd==-1) {
|
if (progfd==-1) {
|
||||||
cause= "Unable to find runtime";
|
BKE_report(reports, RPT_ERROR, "Unable to find runtime.@");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((count= read(progfd, buf, sizeof(buf)))>0) {
|
while ((count= read(progfd, buf, sizeof(buf)))>0) {
|
||||||
if (write(handle, buf, count)!=count) {
|
if (write(handle, buf, count)!=count) {
|
||||||
cause= "Unable to write to output file";
|
BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2336,11 +2332,7 @@ cleanup:
|
|||||||
if (runtime)
|
if (runtime)
|
||||||
MEM_freeN(runtime);
|
MEM_freeN(runtime);
|
||||||
|
|
||||||
if (cause) {
|
return !(reports->flag & RPT_HAS_ERROR);
|
||||||
*cause_r= cause;
|
|
||||||
return 0;
|
|
||||||
} else
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_write_msb_int(int handle, int i)
|
static int handle_write_msb_int(int handle, int i)
|
||||||
@ -2354,17 +2346,16 @@ static int handle_write_msb_int(int handle, int i)
|
|||||||
return (write(handle, buf, 4)==4);
|
return (write(handle, buf, 4)==4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLO_write_runtime(bContext *C, char *file, char *exename)
|
int BLO_write_runtime(bContext *C, char *file, char *exename, ReportList *reports)
|
||||||
{
|
{
|
||||||
int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
|
int outfd= open(file, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
|
||||||
char *cause= NULL;
|
|
||||||
int datastart;
|
int datastart;
|
||||||
|
|
||||||
if (!outfd) {
|
if (!outfd) {
|
||||||
cause= "Unable to open output file";
|
BKE_report(reports, RPT_ERROR, "Unable to open output file.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!handle_append_runtime(outfd, exename, &cause))
|
if (!handle_append_runtime(outfd, exename, reports))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
datastart= lseek(outfd, 0, SEEK_CUR);
|
datastart= lseek(outfd, 0, SEEK_CUR);
|
||||||
@ -2372,7 +2363,7 @@ void BLO_write_runtime(bContext *C, char *file, char *exename)
|
|||||||
write_file_handle(C, outfd, NULL,NULL, 0, G.fileflags);
|
write_file_handle(C, outfd, NULL,NULL, 0, G.fileflags);
|
||||||
|
|
||||||
if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
|
if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
|
||||||
cause= "Unable to write to output file";
|
BKE_report(reports, RPT_ERROR, "Unable to write to output file.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2380,8 +2371,8 @@ cleanup:
|
|||||||
if (outfd!=-1)
|
if (outfd!=-1)
|
||||||
close(outfd);
|
close(outfd);
|
||||||
|
|
||||||
if (cause)
|
//XXX error("Unable to make runtime: %s", cause);
|
||||||
; //XXX error("Unable to make runtime: %s", cause);
|
return !(reports->flag & RPT_HAS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !__APPLE__ */
|
#endif /* !__APPLE__ */
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
#ifndef DNA_FILEGLOBAL_TYPES_H
|
#ifndef DNA_FILEGLOBAL_TYPES_H
|
||||||
#define DNA_FILEGLOBAL_TYPES_H
|
#define DNA_FILEGLOBAL_TYPES_H
|
||||||
|
|
||||||
|
struct bScreen;
|
||||||
|
struct Scene;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileGlobal stores a part of the current user-unterface settings at
|
* FileGlobal stores a part of the current user-unterface settings at
|
||||||
* the moment of saving, and the file-specific settings.
|
* the moment of saving, and the file-specific settings.
|
||||||
@ -40,8 +43,8 @@ typedef struct FileGlobal {
|
|||||||
short subversion, pads;
|
short subversion, pads;
|
||||||
short minversion, minsubversion;
|
short minversion, minsubversion;
|
||||||
short displaymode, winpos;
|
short displaymode, winpos;
|
||||||
void *curscreen;
|
struct bScreen *curscreen;
|
||||||
void *curscene;
|
struct Scene *curscene;
|
||||||
int fileflags;
|
int fileflags;
|
||||||
int globalf;
|
int globalf;
|
||||||
} FileGlobal;
|
} FileGlobal;
|
||||||
|
@ -35,21 +35,23 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct ReportList;
|
||||||
|
|
||||||
BlendFileData *
|
BlendFileData *
|
||||||
BLO_readblenfilename(
|
BLO_readblenfilename(
|
||||||
char *fileName,
|
char *fileName,
|
||||||
BlendReadError *error_r);
|
struct ReportList *reports);
|
||||||
|
|
||||||
BlendFileData *
|
BlendFileData *
|
||||||
BLO_readblenfilehandle(
|
BLO_readblenfilehandle(
|
||||||
int fileHandle,
|
int fileHandle,
|
||||||
BlendReadError *error_r);
|
struct ReportList *reports);
|
||||||
|
|
||||||
BlendFileData *
|
BlendFileData *
|
||||||
BLO_readblenfilememory(
|
BLO_readblenfilememory(
|
||||||
char *fromBuffer,
|
char *fromBuffer,
|
||||||
int fromBufferSize,
|
int fromBufferSize,
|
||||||
BlendReadError *error_r);
|
struct ReportList *reports);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -68,7 +70,7 @@ blo_is_a_runtime(
|
|||||||
BlendFileData *
|
BlendFileData *
|
||||||
blo_read_runtime(
|
blo_read_runtime(
|
||||||
char *file,
|
char *file,
|
||||||
BlendReadError *error_r);
|
struct ReportList *reports);
|
||||||
|
|
||||||
#define BLO_RESERVEDSIZE 12
|
#define BLO_RESERVEDSIZE 12
|
||||||
extern char *headerMagic;
|
extern char *headerMagic;
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "BLO_readblenfile.h"
|
#include "BLO_readblenfile.h"
|
||||||
|
|
||||||
#include "BKE_blender.h"
|
#include "BKE_blender.h"
|
||||||
|
#include "BKE_report.h"
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ cleanup:
|
|||||||
BlendFileData *
|
BlendFileData *
|
||||||
blo_read_runtime(
|
blo_read_runtime(
|
||||||
char *path,
|
char *path,
|
||||||
BlendReadError *error_r)
|
ReportList *reports)
|
||||||
{
|
{
|
||||||
BlendFileData *bfd= NULL;
|
BlendFileData *bfd= NULL;
|
||||||
int fd, actualsize, datastart;
|
int fd, actualsize, datastart;
|
||||||
@ -138,7 +139,7 @@ blo_read_runtime(
|
|||||||
|
|
||||||
fd= open(path, O_BINARY|O_RDONLY, 0);
|
fd= open(path, O_BINARY|O_RDONLY, 0);
|
||||||
if (fd==-1) {
|
if (fd==-1) {
|
||||||
*error_r= BRE_UNABLE_TO_OPEN;
|
BKE_report(reports, RPT_ERROR, "Unable to open");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,18 +149,18 @@ blo_read_runtime(
|
|||||||
|
|
||||||
datastart= handle_read_msb_int(fd);
|
datastart= handle_read_msb_int(fd);
|
||||||
if (datastart==-1) {
|
if (datastart==-1) {
|
||||||
*error_r= BRE_UNABLE_TO_READ;
|
BKE_report(reports, RPT_ERROR, "Unable to read");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (read(fd, buf, 8)!=8) {
|
} else if (read(fd, buf, 8)!=8) {
|
||||||
*error_r= BRE_UNABLE_TO_READ;
|
BKE_report(reports, RPT_ERROR, "Unable to read");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (memcmp(buf, "BRUNTIME", 8)!=0) {
|
} else if (memcmp(buf, "BRUNTIME", 8)!=0) {
|
||||||
*error_r= BRE_NOT_A_BLEND;
|
BKE_report(reports, RPT_ERROR, "File is not a Blender file");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
//printf("starting to read runtime from %s at datastart %d\n", path, datastart);
|
//printf("starting to read runtime from %s at datastart %d\n", path, datastart);
|
||||||
lseek(fd, datastart, SEEK_SET);
|
lseek(fd, datastart, SEEK_SET);
|
||||||
bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, error_r);
|
bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, reports);
|
||||||
fd= -1; // file was closed in blo_read_blendafterruntime()
|
fd= -1; // file was closed in blo_read_blendafterruntime()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "BKE_library.h"
|
#include "BKE_library.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_packedFile.h"
|
#include "BKE_packedFile.h"
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "BKE_texture.h"
|
#include "BKE_texture.h"
|
||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
|
|
||||||
@ -797,7 +798,7 @@ void WM_write_file(bContext *C, char *target)
|
|||||||
Library *li;
|
Library *li;
|
||||||
int writeflags, len;
|
int writeflags, len;
|
||||||
char di[FILE_MAX];
|
char di[FILE_MAX];
|
||||||
char *err;
|
ReportList reports;
|
||||||
|
|
||||||
len = strlen(target);
|
len = strlen(target);
|
||||||
|
|
||||||
@ -843,8 +844,10 @@ void WM_write_file(bContext *C, char *target)
|
|||||||
writeflags= G.fileflags & ~G_FILE_COMPRESS;
|
writeflags= G.fileflags & ~G_FILE_COMPRESS;
|
||||||
if(U.flag & USER_FILECOMPRESS)
|
if(U.flag & USER_FILECOMPRESS)
|
||||||
writeflags |= G_FILE_COMPRESS;
|
writeflags |= G_FILE_COMPRESS;
|
||||||
|
|
||||||
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
|
||||||
if (BLO_write_file(C, di, writeflags, &err)) {
|
if (BLO_write_file(C, di, writeflags, &reports)) {
|
||||||
strcpy(G.sce, di);
|
strcpy(G.sce, di);
|
||||||
G.relbase_valid = 1;
|
G.relbase_valid = 1;
|
||||||
strcpy(G.main->name, di); /* is guaranteed current file */
|
strcpy(G.main->name, di); /* is guaranteed current file */
|
||||||
@ -858,34 +861,45 @@ void WM_write_file(bContext *C, char *target)
|
|||||||
// XXX error("%s", err);
|
// XXX error("%s", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
// XXX waitcursor(0);
|
// XXX waitcursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* operator entry */
|
/* operator entry */
|
||||||
int WM_write_homefile(bContext *C, wmOperator *op)
|
int WM_write_homefile(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
|
ReportList reports;
|
||||||
|
char tstr[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
int write_flags;
|
int write_flags;
|
||||||
|
|
||||||
BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend");
|
BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend");
|
||||||
|
|
||||||
/* force save as regular blend file */
|
/* force save as regular blend file */
|
||||||
write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
|
write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
|
||||||
BLO_write_file(C, tstr, write_flags, &err);
|
|
||||||
|
// XXX error reporting to the user
|
||||||
|
BKE_reports_init(&reports, RPT_PRINT);
|
||||||
|
BLO_write_file(C, tstr, write_flags, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WM_write_autosave(bContext *C)
|
void WM_write_autosave(bContext *C)
|
||||||
{
|
{
|
||||||
char *err, tstr[FILE_MAXDIR+FILE_MAXFILE];
|
ReportList reports;
|
||||||
|
char tstr[FILE_MAXDIR+FILE_MAXFILE];
|
||||||
int write_flags;
|
int write_flags;
|
||||||
|
|
||||||
get_autosave_location(tstr);
|
get_autosave_location(tstr);
|
||||||
|
|
||||||
/* force save as regular blend file */
|
/* force save as regular blend file */
|
||||||
write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
|
write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN);
|
||||||
BLO_write_file(C, tstr, write_flags, &err);
|
|
||||||
|
BKE_reports_init(&reports, RPT_PRINT);
|
||||||
|
BLO_write_file(C, tstr, write_flags, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if global undo; remove tempsave, otherwise rename */
|
/* if global undo; remove tempsave, otherwise rename */
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
//XXX #include "BIF_screen.h"
|
//XXX #include "BIF_screen.h"
|
||||||
//XXX #include "BIF_scrarea.h"
|
//XXX #include "BIF_scrarea.h"
|
||||||
@ -91,12 +92,21 @@ void update_for_newframe();
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BlendFileData *load_game_data(char *filename) {
|
static BlendFileData *load_game_data(char *filename)
|
||||||
BlendReadError error;
|
{
|
||||||
BlendFileData *bfd= BLO_read_from_file(filename, &error);
|
ReportList reports;
|
||||||
|
BlendFileData *bfd;
|
||||||
|
|
||||||
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
bfd= BLO_read_from_file(filename, &reports);
|
||||||
|
|
||||||
if (!bfd) {
|
if (!bfd) {
|
||||||
printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
|
printf("Loading %s failed: ", filename);
|
||||||
|
BKE_reports_print(&reports, RPT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
return bfd;
|
return bfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "BKE_blender.h" // initglobals()
|
#include "BKE_blender.h" // initglobals()
|
||||||
#include "BKE_global.h" // Global G
|
#include "BKE_global.h" // Global G
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_camera_types.h" // Camera
|
#include "DNA_camera_types.h" // Camera
|
||||||
#include "DNA_object_types.h" // Object
|
#include "DNA_object_types.h" // Object
|
||||||
@ -135,15 +136,19 @@ GPC_Engine::~GPC_Engine()
|
|||||||
|
|
||||||
bool GPC_Engine::Start(char *filename)
|
bool GPC_Engine::Start(char *filename)
|
||||||
{
|
{
|
||||||
BlendReadError error;
|
ReportList reports;
|
||||||
BlendFileData *bfd= BLO_read_from_file(filename, &error);
|
BlendFileData *bfd;
|
||||||
|
|
||||||
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
bfd= BLO_read_from_file(filename, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
if (!bfd) {
|
if (!bfd) {
|
||||||
// XXX, deal with error here
|
// XXX, deal with error here
|
||||||
cout << "Unable to load: " << filename << endl;
|
cout << "Unable to load: " << filename << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartKetsji();
|
StartKetsji();
|
||||||
|
|
||||||
if(bfd->type == BLENFILETYPE_PUB)
|
if(bfd->type == BLENFILETYPE_PUB)
|
||||||
@ -156,8 +161,12 @@ bool GPC_Engine::Start(char *filename)
|
|||||||
bool GPC_Engine::Start(unsigned char *blenderDataBuffer,
|
bool GPC_Engine::Start(unsigned char *blenderDataBuffer,
|
||||||
unsigned int blenderDataBufferSize)
|
unsigned int blenderDataBufferSize)
|
||||||
{
|
{
|
||||||
BlendReadError error;
|
ReportList reports;
|
||||||
BlendFileData *bfd= BLO_read_from_memory(blenderDataBuffer, blenderDataBufferSize, &error);
|
BlendFileData *bfd;
|
||||||
|
|
||||||
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
bfd= BLO_read_from_memory(blenderDataBuffer, blenderDataBufferSize, &reports);
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
if (!bfd) {
|
if (!bfd) {
|
||||||
// XXX, deal with error here
|
// XXX, deal with error here
|
||||||
|
@ -58,6 +58,7 @@ extern "C"
|
|||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_icons.h"
|
#include "BKE_icons.h"
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
|
#include "BKE_report.h"
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "BLO_readfile.h"
|
#include "BLO_readfile.h"
|
||||||
@ -251,35 +252,33 @@ static void get_filename(int argc, char **argv, char *filename)
|
|||||||
#endif // !_APPLE
|
#endif // !_APPLE
|
||||||
}
|
}
|
||||||
|
|
||||||
static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL) {
|
static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL)
|
||||||
BlendReadError error;
|
{
|
||||||
|
ReportList reports;
|
||||||
BlendFileData *bfd = NULL;
|
BlendFileData *bfd = NULL;
|
||||||
|
|
||||||
|
BKE_reports_init(&reports, RPT_STORE);
|
||||||
|
|
||||||
/* try to load ourself, will only work if we are a runtime */
|
/* try to load ourself, will only work if we are a runtime */
|
||||||
if (blo_is_a_runtime(progname)) {
|
if (blo_is_a_runtime(progname)) {
|
||||||
bfd= blo_read_runtime(progname, &error);
|
bfd= blo_read_runtime(progname, &reports);
|
||||||
if (bfd) {
|
if (bfd) {
|
||||||
bfd->type= BLENFILETYPE_RUNTIME;
|
bfd->type= BLENFILETYPE_RUNTIME;
|
||||||
strcpy(bfd->main->name, progname);
|
strcpy(bfd->main->name, progname);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bfd= BLO_read_from_file(progname, &error);
|
bfd= BLO_read_from_file(progname, &reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (bfd && bfd->type == BLENFILETYPE_BLEND) {
|
|
||||||
BLO_blendfiledata_free(bfd);
|
|
||||||
bfd = NULL;
|
|
||||||
error = BRE_NOT_A_PUBFILE;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!bfd && filename) {
|
if (!bfd && filename) {
|
||||||
bfd = load_game_data(filename);
|
bfd = load_game_data(filename);
|
||||||
if (!bfd) {
|
if (!bfd) {
|
||||||
printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
|
printf("Loading %s failed: ", filename);
|
||||||
|
BKE_reports_print(&reports, RPT_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BKE_reports_clear(&reports);
|
||||||
|
|
||||||
return bfd;
|
return bfd;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user