diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2005-03-19 21:23:05 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2005-03-19 21:23:05 +0300 |
commit | dd17f7e725a9380c1e73b90cab8465bc0546fb8e (patch) | |
tree | 2f66bb4e4a89d1471d1ae90869a2ec9d0eca9a1e /source/blender/python/api2_2x/Blender.c | |
parent | 0d1738e285c079a03fb9c0a2f5a68c0a1b38939f (diff) |
BPython:
- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).
Trying to fix two mistakes from my previous commit:
- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.
- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess. I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:
max depth for traversing subdirs = 4
max dirs in the tree = 30.
I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing. Sorry about the mess, I should take lessons on defensive programming ...
Diffstat (limited to 'source/blender/python/api2_2x/Blender.c')
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index c1ecbdf7ebb..a38847baab8 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -233,12 +233,20 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args ) ret = EXPP_incr_ret( Py_None ); } else if(StringEqual(str, "udatadir")) { - char udatadir[FILE_MAXDIR]; + if (U.pythondir[0] != '\0') { + char upydir[FILE_MAXDIR]; - if (BLI_exists(U.pythondir)) { - BLI_make_file_string("/", udatadir, U.pythondir, "bpydata/"); - if (BLI_exists(udatadir)) - ret = PyString_FromString(udatadir); + BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR); + BLI_convertstringcode(upydir, G.sce, 0); + + if (BLI_exists(upydir)) { + char udatadir[FILE_MAXDIR]; + + BLI_make_file_string("/", udatadir, upydir, "bpydata/"); + + if (BLI_exists(udatadir)) + ret = PyString_FromString(udatadir); + } } if (!ret) ret = EXPP_incr_ret(Py_None); } @@ -247,14 +255,20 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args ) if (sdir) ret = PyString_FromString(sdir); - else - ret = EXPP_incr_ret( Py_None ); + else + ret = EXPP_incr_ret( Py_None ); } else if( StringEqual( str, "uscriptsdir" ) ) { - if( BLI_exists( U.pythondir ) ) - ret = PyString_FromString( U.pythondir ); - else - ret = EXPP_incr_ret( Py_None ); + if (U.pythondir[0] != '\0') { + char upydir[FILE_MAXDIR]; + + BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR); + BLI_convertstringcode(upydir, G.sce, 0); + + if( BLI_exists( upydir ) ) + ret = PyString_FromString( upydir ); + } + if (!ret) ret = EXPP_incr_ret(Py_None); } /* According to the old file (opy_blender.c), the following if statement is a quick hack and needs some clean up. */ |