Example #1
0
int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
{
	BlendFileData *bfd;
	int retval = BKE_READ_FILE_OK;

	if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) /* don't print user-pref loading */
		printf("read blend: %s\n", filepath);

	bfd = BLO_read_from_file(filepath, reports);
	if (bfd) {
		if (bfd->user) retval = BKE_READ_FILE_OK_USERPREFS;
		
		if (0 == handle_subversion_warning(bfd->main, reports)) {
			BKE_main_free(bfd->main);
			MEM_freeN(bfd);
			bfd = NULL;
			retval = BKE_READ_FILE_FAIL;
		}
		else
			setup_app_data(C, bfd, filepath);  // frees BFD
	}
	else
		BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);
		
	return (bfd ? retval : BKE_READ_FILE_FAIL);
}
Example #2
0
int BKE_blendfile_read(
        bContext *C, const char *filepath,
        const struct BlendFileReadParams *params,
        ReportList *reports)
{
	BlendFileData *bfd;
	int retval = BKE_BLENDFILE_READ_OK;

	/* don't print user-pref loading */
	if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) {
		printf("Read blend: %s\n", filepath);
	}

	bfd = BLO_read_from_file(filepath, params->skip_flags, reports);
	if (bfd) {
		if (bfd->user) {
			retval = BKE_BLENDFILE_READ_OK_USERPREFS;
		}

		if (0 == handle_subversion_warning(bfd->main, reports)) {
			BKE_main_free(bfd->main);
			MEM_freeN(bfd);
			bfd = NULL;
			retval = BKE_BLENDFILE_READ_FAIL;
		}
		else {
			setup_app_data(C, bfd, filepath, params->is_startup, reports);
		}
	}
	else
		BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath);

	return (bfd ? retval : BKE_BLENDFILE_READ_FAIL);
}
Example #3
0
int BKE_read_file_from_memory(bContext *C, char *filebuf, int filelength, ReportList *reports)
{
	BlendFileData *bfd;

	bfd = BLO_read_from_memory(filebuf, filelength, reports);
	if (bfd)
		setup_app_data(C, bfd, "<memory2>");
	else
		BKE_reports_prepend(reports, "Loading failed: ");

	return (bfd ? 1 : 0);
}
Example #4
0
/* memfile is the undo buffer */
int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *reports)
{
	BlendFileData *bfd;

	bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
	if (bfd)
		setup_app_data(C, bfd, "<memory1>");
	else
		BKE_reports_prepend(reports, "Loading failed: ");

	return (bfd?1:0);
}
Example #5
0
int BKE_read_file_from_memory(bContext *C, const void *filebuf, int filelength, ReportList *reports, int update_defaults)
{
	BlendFileData *bfd;

	bfd = BLO_read_from_memory(filebuf, filelength, reports);
	if (bfd) {
		if (update_defaults)
			BLO_update_defaults_startup_blend(bfd->main);
		setup_app_data(C, bfd, "<memory2>");
	}
	else
		BKE_reports_prepend(reports, "Loading failed: ");

	return (bfd ? 1 : 0);
}
Example #6
0
bool BKE_blendfile_read_from_memory(
        bContext *C, const void *filebuf, int filelength,
        ReportList *reports, int skip_flags, bool update_defaults)
{
	BlendFileData *bfd;

	bfd = BLO_read_from_memory(filebuf, filelength, reports, skip_flags);
	if (bfd) {
		if (update_defaults)
			BLO_update_defaults_startup_blend(bfd->main);
		setup_app_data(C, bfd, "<memory2>", reports);
	}
	else {
		BKE_reports_prepend(reports, "Loading failed: ");
	}

	return (bfd != NULL);
}
Example #7
0
/* memfile is the undo buffer */
int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *reports)
{
	BlendFileData *bfd;

	bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports);
	if (bfd) {
		/* remove the unused screens and wm */
		while (bfd->main->wm.first)
			BKE_libblock_free(&bfd->main->wm, bfd->main->wm.first);
		while (bfd->main->screen.first)
			BKE_libblock_free(&bfd->main->screen, bfd->main->screen.first);
		
		setup_app_data(C, bfd, "<memory1>");
	}
	else
		BKE_reports_prepend(reports, "Loading failed: ");

	return (bfd ? 1 : 0);
}
Example #8
0
/* memfile is the undo buffer */
bool BKE_blendfile_read_from_memfile(
        bContext *C, struct MemFile *memfile,
        ReportList *reports, int skip_flags)
{
	Main *bmain = CTX_data_main(C);
	BlendFileData *bfd;

	bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, reports, skip_flags);
	if (bfd) {
		/* remove the unused screens and wm */
		while (bfd->main->wm.first)
			BKE_libblock_free(bfd->main, bfd->main->wm.first);
		while (bfd->main->screen.first)
			BKE_libblock_free(bfd->main, bfd->main->screen.first);

		setup_app_data(C, bfd, "<memory1>", reports);
	}
	else {
		BKE_reports_prepend(reports, "Loading failed: ");
	}

	return (bfd != NULL);
}