[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36620] trunk/blender: Code cleanup: remove readblenfile module, only contained some utility functions
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed May 11 21:29:23 CEST 2011
Revision: 36620
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36620
Author: blendix
Date: 2011-05-11 19:29:23 +0000 (Wed, 11 May 2011)
Log Message:
-----------
Code cleanup: remove readblenfile module, only contained some utility functions
to read .blend files from runtimes, folded those into blenloader.
Modified Paths:
--------------
trunk/blender/doc/doxygen/doxygen.source
trunk/blender/source/blender/CMakeLists.txt
trunk/blender/source/blender/SConscript
trunk/blender/source/blender/blenloader/CMakeLists.txt
trunk/blender/source/blender/blenloader/SConscript
trunk/blender/source/blender/blenloader/intern/readblenentry.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blenderplayer/CMakeLists.txt
trunk/blender/source/creator/CMakeLists.txt
trunk/blender/source/gameengine/GamePlayer/ghost/CMakeLists.txt
trunk/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
trunk/blender/source/gameengine/GamePlayer/ghost/SConscript
Added Paths:
-----------
trunk/blender/source/blender/blenloader/BLO_runtime.h
trunk/blender/source/blender/blenloader/intern/runtime.c
Removed Paths:
-------------
trunk/blender/source/blender/readblenfile/
Modified: trunk/blender/doc/doxygen/doxygen.source
===================================================================
--- trunk/blender/doc/doxygen/doxygen.source 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/doc/doxygen/doxygen.source 2011-05-11 19:29:23 UTC (rev 36620)
@@ -145,10 +145,6 @@
* merged in docs.
*/
-/** \defgroup blo readblenfile
- * \ingroup blender data
- */
-
/** \defgroup quicktime quicktime
* \ingroup blender
Modified: trunk/blender/source/blender/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/CMakeLists.txt 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blender/CMakeLists.txt 2011-05-11 19:29:23 UTC (rev 36620)
@@ -91,7 +91,6 @@
add_subdirectory(render)
add_subdirectory(blenfont)
add_subdirectory(blenloader)
-add_subdirectory(readblenfile)
add_subdirectory(blenpluginapi)
add_subdirectory(ikplugin)
add_subdirectory(gpu)
Modified: trunk/blender/source/blender/SConscript
===================================================================
--- trunk/blender/source/blender/SConscript 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blender/SConscript 2011-05-11 19:29:23 UTC (rev 36620)
@@ -12,7 +12,6 @@
'imbuf/SConscript',
'makesdna/SConscript',
'makesrna/SConscript',
- 'readblenfile/SConscript',
'render/SConscript',
'nodes/SConscript',
'modifiers/SConscript',
Copied: trunk/blender/source/blender/blenloader/BLO_runtime.h (from rev 36613, trunk/blender/source/blender/readblenfile/BLO_readblenfile.h)
===================================================================
--- trunk/blender/source/blender/blenloader/BLO_runtime.h (rev 0)
+++ trunk/blender/source/blender/blenloader/BLO_runtime.h 2011-05-11 19:29:23 UTC (rev 36620)
@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+#ifndef BLO_RUNTIME_H
+#define BLO_RUNTIME_H
+
+/** \file BLO_runtime.h
+ * \ingroup blenloader
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct BlendFileData;
+struct ReportList;
+
+int BLO_is_a_runtime(char *file);
+struct BlendFileData *BLO_read_runtime(char *file, struct ReportList *reports);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BLO_RUNTIME_H */
+
Modified: trunk/blender/source/blender/blenloader/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenloader/CMakeLists.txt 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blender/blenloader/CMakeLists.txt 2011-05-11 19:29:23 UTC (rev 36620)
@@ -29,7 +29,6 @@
../blenlib
../blenkernel
../makesdna
- ../readblenfile
../makesrna
../render/extern/include
../../../intern/guardedalloc
@@ -39,10 +38,12 @@
set(SRC
intern/readblenentry.c
intern/readfile.c
+ intern/runtime.c
intern/undofile.c
intern/writefile.c
BLO_readfile.h
+ BLO_runtime.h
BLO_soundfile.h
BLO_sys_types.h
BLO_undofile.h
Modified: trunk/blender/source/blender/blenloader/SConscript
===================================================================
--- trunk/blender/source/blender/blenloader/SConscript 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blender/blenloader/SConscript 2011-05-11 19:29:23 UTC (rev 36620)
@@ -4,7 +4,7 @@
sources = env.Glob('intern/*.c')
incs = '. #/intern/guardedalloc ../blenlib ../blenkernel'
-incs += ' ../makesdna ../readblenfile ../editors/include'
+incs += ' ../makesdna ../editors/include'
incs += ' ../render/extern/include ../makesrna'
incs += ' ' + env['BF_ZLIB_INC']
Modified: trunk/blender/source/blender/blenloader/intern/readblenentry.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readblenentry.c 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blender/blenloader/intern/readblenentry.c 2011-05-11 19:29:23 UTC (rev 36620)
@@ -62,8 +62,6 @@
#include "readfile.h"
-#include "BLO_readblenfile.h"
-
#include "BLO_sys_types.h" // needed for intptr_t
#ifdef _WIN32
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2011-05-11 19:29:23 UTC (rev 36620)
@@ -137,7 +137,6 @@
//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo
#include "BLO_readfile.h"
#include "BLO_undofile.h"
-#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
#include "readfile.h"
Copied: trunk/blender/source/blender/blenloader/intern/runtime.c (from rev 36613, trunk/blender/source/blender/readblenfile/intern/BLO_readblenfile.c)
===================================================================
--- trunk/blender/source/blender/blenloader/intern/runtime.c (rev 0)
+++ trunk/blender/source/blender/blenloader/intern/runtime.c 2011-05-11 19:29:23 UTC (rev 36620)
@@ -0,0 +1,145 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/**
+ * \file runtime.c
+ * \brief This file handles the loading of .blend files embedded in runtimes
+ * \ingroup blenloader
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#ifdef WIN32
+#include <io.h> // read, open
+#include "BLI_winstuff.h"
+#else // ! WIN32
+#include <unistd.h> // read
+#endif
+
+#include "BLO_readfile.h"
+#include "BLO_runtime.h"
+
+#include "BKE_blender.h"
+#include "BKE_report.h"
+#include "BKE_utildefines.h"
+
+#include "BLI_blenlib.h"
+
+/* Runtime reading */
+
+static int handle_read_msb_int(int handle)
+{
+ unsigned char buf[4];
+
+ if(read(handle, buf, 4) != 4)
+ return -1;
+
+ return (buf[0]<<24) + (buf[1]<<16) + (buf[2]<<8) + (buf[3]<<0);
+}
+
+int BLO_is_a_runtime(char *path)
+{
+ int res= 0, fd= open(path, O_BINARY|O_RDONLY, 0);
+ int datastart;
+ char buf[8];
+
+ if(fd==-1)
+ goto cleanup;
+
+ lseek(fd, -12, SEEK_END);
+
+ datastart= handle_read_msb_int(fd);
+
+ if(datastart==-1)
+ goto cleanup;
+ else if(read(fd, buf, 8)!=8)
+ goto cleanup;
+ else if(memcmp(buf, "BRUNTIME", 8)!=0)
+ goto cleanup;
+ else
+ res= 1;
+
+cleanup:
+ if(fd!=-1)
+ close(fd);
+
+ return res;
+}
+
+BlendFileData *BLO_read_runtime(char *path, ReportList *reports)
+{
+ BlendFileData *bfd= NULL;
+ size_t actualsize;
+ int fd, datastart;
+ char buf[8];
+
+ fd= open(path, O_BINARY|O_RDONLY, 0);
+
+ if(fd==-1) {
+ BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", path, strerror(errno));
+ goto cleanup;
+ }
+
+ actualsize= BLI_filesize(fd);
+
+ lseek(fd, -12, SEEK_END);
+
+ datastart= handle_read_msb_int(fd);
+
+ if(datastart==-1) {
+ BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (problem seeking)", path);
+ goto cleanup;
+ }
+ else if(read(fd, buf, 8)!=8) {
+ BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (truncated header)", path);
+ goto cleanup;
+ }
+ else if(memcmp(buf, "BRUNTIME", 8)!=0) {
+ BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (not a blend file)", path);
+ goto cleanup;
+ }
+ else {
+ //printf("starting to read runtime from %s at datastart %d\n", path, datastart);
+ lseek(fd, datastart, SEEK_SET);
+ bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, reports);
+ fd= -1; // file was closed in blo_read_blendafterruntime()
+ }
+
+cleanup:
+ if(fd!=-1)
+ close(fd);
+
+ return bfd;
+}
+
Modified: trunk/blender/source/blenderplayer/CMakeLists.txt
===================================================================
--- trunk/blender/source/blenderplayer/CMakeLists.txt 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/blenderplayer/CMakeLists.txt 2011-05-11 19:29:23 UTC (rev 36620)
@@ -127,7 +127,6 @@
extern_openjpeg
extern_redcode
bf_imbuf_dds
- bf_readblenfile
bf_dna
ge_videotex
bf_blenfont
Modified: trunk/blender/source/creator/CMakeLists.txt
===================================================================
--- trunk/blender/source/creator/CMakeLists.txt 2011-05-11 19:20:26 UTC (rev 36619)
+++ trunk/blender/source/creator/CMakeLists.txt 2011-05-11 19:29:23 UTC (rev 36620)
@@ -771,7 +771,6 @@
bf_imbuf_cineon
bf_imbuf_openexr
bf_imbuf_dds
- bf_readblenfile
bf_collada
bf_intern_bsp
bf_intern_bop
Modified: trunk/blender/source/gameengine/GamePlayer/ghost/CMakeLists.txt
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list