Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/exotic.c')
-rw-r--r--source/blender/blenkernel/intern/exotic.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index e695c40401a..30cad2b6d2f 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -74,7 +74,7 @@
#include "BKE_object.h"
#include "BKE_material.h"
#include "BKE_report.h"
-
+#include "BKE_exotic.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
#include "BKE_curve.h"
@@ -458,49 +458,50 @@ int BKE_read_exotic(Scene *scene, const char *name)
{
int len;
gzFile gzfile;
- char str[32];
- int *s0 = (int*) str;
- int retval = 0;
+ int head[2];
+ int retval;
// make sure we're not trying to read a directory....
len= strlen(name);
- if (name[len-1] !='/' && name[len-1] != '\\') {
+ if (ELEM(name[len-1], '/', '\\')) {
+ retval= BKE_READ_EXOTIC_FAIL_PATH;
+ }
+ else {
gzfile = gzopen(name,"rb");
- if (NULL == gzfile ) {
- //XXX error("Can't open file: %s", name);
- retval= -1;
- } else {
- gzread(gzfile, str, 31);
+ if (gzfile == NULL) {
+ retval= BKE_READ_EXOTIC_FAIL_OPEN;
+ }
+ else {
+ len= gzread(gzfile, &head, sizeof(head));
gzclose(gzfile);
- if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) {
-
+ if (len == sizeof(head) && (head[0] == BLEN && head[1] == DER_)) {
+ retval= BKE_READ_EXOTIC_OK_BLEND;
+ }
+ else {
//XXX waitcursor(1);
if(is_dxf(name)) {
dxf_read(scene, name);
- retval = 1;
+ retval= BKE_READ_EXOTIC_OK_OTHER;
}
else if(is_stl(name)) {
if (is_stl_ascii(name))
read_stl_mesh_ascii(scene, name);
else
read_stl_mesh_binary(scene, name);
- retval = 1;
+ retval= BKE_READ_EXOTIC_OK_OTHER;
}
-#ifdef WITH_PYTHON
- // TODO: this should not be in the kernel...
- else { // unknown format, call Python importloader
- /* pass */
+ else {
+ retval= BKE_READ_EXOTIC_FAIL_FORMAT;
}
-#endif /* WITH_PYTHON */
//XXX waitcursor(0);
}
}
}
- return (retval);
+ return retval;
}