diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-19 03:50:21 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-19 03:50:21 +0300 |
commit | d9de6fca6cda2a7ddeeb936692b529182a14dec9 (patch) | |
tree | 63b5384fe03297bdfb40205c280b36ec043d0ed1 /source/blender/blenloader | |
parent | ea81c58429ecd51752e2abb7d756ef1d09514b84 (diff) |
2.5: Change blenloader module to use the Report system for reporting errors.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 69 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_writefile.h | 7 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 68 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 46 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.h | 11 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 73 |
6 files changed, 103 insertions, 171 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 1219b1ba0c5..38f8be58bf6 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -34,16 +34,17 @@ extern "C" { #endif -struct SpaceFile; -struct SpaceImaSel; +struct bScreen; +struct direntry; struct FileList; struct LinkNode; struct Main; -struct UserDef; -struct bScreen; -struct Scene; struct MemFile; -struct direntry; +struct ReportList; +struct Scene; +struct SpaceFile; +struct SpaceImaSel; +struct UserDef; typedef struct BlendHandle BlendHandle; @@ -53,29 +54,6 @@ typedef enum BlenFileType { BLENFILETYPE_RUNTIME= 3 } 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 { struct Main* main; struct UserDef* user; @@ -93,46 +71,33 @@ typedef struct BlendFileData { /** * 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. * * @param file The path of the file to open. - * @param error_r If the return value is NULL, an error - * code indicating the cause of the failure. + * @param reports If the return value is NULL, errors + * indicating the cause of the failure. * @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 - * 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. * * @param mem The file data. * @param memsize The length of @a mem. - * @param error_r If the return value is NULL, an error - * code indicating the cause of the failure. + * @param reports If the return value is NULL, errors + * indicating the cause of the failure. * @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 */ -BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, BlendReadError *error_r); - -/** - * 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); +BlendFileData *BLO_read_from_memfile(const char *filename, struct MemFile *memfile, struct ReportList *reports); /** * 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); 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 } diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 0b88cb1fb77..8205a43f39f 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -33,11 +33,12 @@ struct MemFile; 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, - int write_flags, char **error_r); -extern void BLO_write_runtime(struct bContext *C, char *file, char *exename); + int write_flags, struct ReportList *reports); +extern int BLO_write_runtime(struct bContext *C, char *file, char *exename, struct ReportList *reports); #endif diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index d5f5bb663ab..d7acfc7eed0 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -55,6 +55,7 @@ #include "BKE_main.h" #include "BKE_global.h" #include "BKE_library.h" // for free_main +#include "BKE_report.h" #include "BLO_readfile.h" #include "BLO_undofile.h" @@ -166,9 +167,14 @@ int BLO_idcode_from_name(char *name) 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) @@ -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; FileData *fd; - fd = blo_openblenderfile(file, error_r); + fd = blo_openblenderfile(file, reports); if (fd) { - bfd= blo_read_file_internal(fd, error_r); + bfd= blo_read_file_internal(fd, reports); if (bfd) { bfd->type= BLENFILETYPE_BLEND; 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; } -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; FileData *fd; - fd = blo_openblendermemory(mem, memsize, error_r); + fd = blo_openblendermemory(mem, memsize, reports); if (fd) { - bfd= blo_read_file_internal(fd, error_r); + bfd= blo_read_file_internal(fd, reports); if (bfd) { bfd->type= BLENFILETYPE_BLEND; strcpy(bfd->main->name, ""); @@ -354,13 +360,13 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, BlendReadError *erro 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; FileData *fd; ListBase mainlist; - fd = blo_openblendermemfile(memfile, error_r); + fd = blo_openblendermemfile(memfile, reports); if (fd) { 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 */ blo_make_image_pointer_map(fd); - bfd= blo_read_file_internal(fd, error_r); + bfd= blo_read_file_internal(fd, reports); if (bfd) { bfd->type= BLENFILETYPE_BLEND; strcpy(bfd->main->name, ""); @@ -416,43 +422,3 @@ void BLO_blendfiledata_free(BlendFileData *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>"; - } -} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 94c11e9d2e1..29624383474 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -129,6 +129,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_property.h" // for get_ob_property +#include "BKE_report.h" #include "BKE_sca.h" // for init_actuator #include "BKE_scene.h" #include "BKE_softbody.h" // sbNew() @@ -925,19 +926,19 @@ static FileData *filedata_new(void) 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); if (fd->flags & FD_FLAGS_FILE_OK) { if (!read_file_dna(fd)) { - *error_r = BRE_INCOMPLETE; + BKE_report(reports, RPT_ERROR, "File incomplete"); blo_freefiledata(fd); fd= NULL; } } else { - *error_r = BRE_NOT_A_BLEND; + BKE_report(reports, RPT_ERROR, "File is not a Blender file"); blo_freefiledata(fd); fd= NULL; } @@ -947,14 +948,14 @@ static FileData *blo_decode_and_check(FileData *fd, BlendReadError *error_r) /* cannot be called with relative paths anymore! */ /* 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= gzopen(name, "rb"); if (NULL == gzfile) { - *error_r = BRE_UNABLE_TO_OPEN; + BKE_report(reports, RPT_ERROR, "Unable to open"); return NULL; } else { FileData *fd = filedata_new(); @@ -964,14 +965,14 @@ FileData *blo_openblenderfile(char *name, BlendReadError *error_r) /* needed for library_append and read_libraries */ 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) { - *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; } else { 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->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) { - *error_r = BRE_UNABLE_TO_OPEN; + BKE_report(reports, RPT_ERROR, "Unable to open"); return NULL; } else { FileData *fd= filedata_new(); @@ -996,7 +997,7 @@ FileData *blo_openblendermemfile(MemFile *memfile, BlendReadError *error_r) fd->read= fd_read_from_memfile; 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; } - 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); //XXX error("Library had multiple instances, save and reload!"); + BKE_report(fd->reports, RPT_WARNING, "Library had multiple instances, save and reload!"); + return; } } @@ -8350,7 +8354,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *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); BlendFileData *bfd; @@ -9538,9 +9542,13 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) FileData *fd= mainptr->curlib->filedata; if(fd==NULL) { - BlendReadError err; + ReportList reports; + 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->libmap) oldnewmap_free(fd->libmap); @@ -9639,7 +9647,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) /* 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; 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 */ 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) return NULL; - bfd= blo_read_file_internal(fd, error_r); + bfd= blo_read_file_internal(fd, reports); blo_freefiledata(fd); return bfd; diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 8547a4d9652..f53f3c6c883 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -35,6 +35,7 @@ struct OldNewMap; struct MemFile; struct bheadsort; +struct ReportList; typedef struct FileData { // linked list of BHeadN's @@ -83,7 +84,7 @@ typedef struct FileData { * data through streamglue. */ BlendFileData **bfd_r; - BlendReadError *error_r; + struct ReportList *reports; } FileData; typedef struct BHeadN { @@ -106,11 +107,11 @@ struct Main; void blo_join_main(ListBase *mainlist); 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_openblendermemory( void *buffer, int buffersize, BlendReadError *error_r); -FileData *blo_openblendermemfile(struct MemFile *memfile, BlendReadError *error_r); +FileData *blo_openblenderfile( char *name, struct ReportList *reports); +FileData *blo_openblendermemory( void *buffer, int buffersize, struct ReportList *reports); +FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports); void blo_clear_proxy_pointers_from_lib(FileData *fd); void blo_make_image_pointer_map(FileData *fd); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 1c44217bde0..6cd2d328c82 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -155,6 +155,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_main.h" // G.main #include "BKE_node.h" #include "BKE_packedFile.h" // for packAll +#include "BKE_report.h" #include "BKE_screen.h" // for waitcursor #include "BKE_sequence.h" #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) */ -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 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); if(file == -1) { - *error_r= "Unable to open"; + BKE_report(reports, RPT_ERROR, "Unable to open file for writing."); 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); if(-1==ret) { - *error_r= "Failed opening .gz file"; + BKE_report(reports, RPT_ERROR, "Failed opening .gz file."); return 0; } if(-2==ret) { - *error_r= "Failed opening .blend file for compression"; + BKE_report(reports, RPT_ERROR, "Failed opening .blend file for compression."); return 0; } } else 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; } } else { - *error_r= strerror(errno); + BKE_report(reports, RPT_ERROR, strerror(errno)); remove(tempname); return 0; @@ -2165,7 +2166,7 @@ int BLO_write_file(bContext *C, char *dir, int write_flags, char **error_r) } /* 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; @@ -2230,28 +2231,28 @@ static char *get_runtime_path(char *exename) { #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]; int progfd = -1; if (!runtime) { - cause= "Unable to find runtime"; + BKE_report(reports, RPT_ERROR, "Unable to find runtime"); goto cleanup; } //printf("runtimepath %s\n", runtime); progfd= open(runtime, O_BINARY|O_RDONLY, 0); if (progfd==-1) { - cause= "Unable to find runtime"; + BKE_report(reports, RPT_ERROR, "Unable to find runtime"); goto cleanup; } sprintf(command, "/bin/cp -R \"%s\" \"%s\"", runtime, outname); //printf("command %s\n", command); if (system(command) == -1) { - cause = "Couldn't copy runtime"; + BKE_report(reports, RPT_ERROR, "Couldn't copy runtime"); } cleanup: @@ -2260,24 +2261,19 @@ cleanup: if (runtime) MEM_freeN(runtime); - if (cause) { - *cause_r= cause; - return 0; - } else - return 1; + return !(reports->flag & RPT_HAS_ERROR); } -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]; int outfd = -1; - char *cause= NULL; // remove existing file / bundle //printf("Delete file %s\n", file); BLI_delete(file, 0, TRUE); - if (!recursive_copy_runtime(file, exename, &cause)) + if (!recursive_copy_runtime(file, exename, reports)) goto cleanup; 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); 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; } } else { - cause = "Unable to open blenderfile"; + BKE_report(reports, RPT_ERROR, "Unable to open blenderfile."); } cleanup: if (outfd!=-1) close(outfd); - if (cause) - error("Unable to make runtime: %s", cause); + //XXX error("Unable to make runtime: %s", cause); + return !(reports->flag & RPT_HAS_ERROR); } #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]; int count, progfd= -1; if (!BLI_exists(runtime)) { - cause= "Unable to find runtime"; + BKE_report(reports, RPT_ERROR, "Unable to find runtime."); goto cleanup; } progfd= open(runtime, O_BINARY|O_RDONLY, 0); if (progfd==-1) { - cause= "Unable to find runtime"; + BKE_report(reports, RPT_ERROR, "Unable to find runtime.@"); goto cleanup; } while ((count= read(progfd, buf, sizeof(buf)))>0) { 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; } } @@ -2336,11 +2332,7 @@ cleanup: if (runtime) MEM_freeN(runtime); - if (cause) { - *cause_r= cause; - return 0; - } else - return 1; + return !(reports->flag & RPT_HAS_ERROR); } 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); } -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); - char *cause= NULL; int datastart; if (!outfd) { - cause= "Unable to open output file"; + BKE_report(reports, RPT_ERROR, "Unable to open output file."); goto cleanup; } - if (!handle_append_runtime(outfd, exename, &cause)) + if (!handle_append_runtime(outfd, exename, reports)) goto cleanup; 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); 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; } @@ -2380,8 +2371,8 @@ cleanup: if (outfd!=-1) 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__ */ |