diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2003-12-14 04:18:09 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2003-12-14 04:18:09 +0300 |
commit | 49021f7ec4bfc1313c6cdfeae1f9c32e98cc9cdc (patch) | |
tree | 44e7c4c38bc8c26b5efe0b52b846402589a4ca9a /source/blender/python/api2_2x/Sys.c | |
parent | 6653af79142aa929eb3d131f8fced363b2c4b828 (diff) |
BPython - first step for better integration of Python in Blender:
- add a new space: Space Script
- add a new dna struct: Script
- add these two properly everywhere they are meant to
It's not a tiny commit, but most of it is ground work for what is still to be done.
Right now the benefits should be: freeing the Text Editor to be used in a window even while a script w/ gui in "on" and letting more than one currently running script w/ gui be accessible from each window
Some files are added, so some build systems (not autotools) will need updates
Diffstat (limited to 'source/blender/python/api2_2x/Sys.c')
-rw-r--r-- | source/blender/python/api2_2x/Sys.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c index 4528d41933a..29c54785595 100644 --- a/source/blender/python/api2_2x/Sys.c +++ b/source/blender/python/api2_2x/Sys.c @@ -62,7 +62,7 @@ static PyObject *M_sys_dirname (PyObject *self, PyObject *args) { PyObject *c; - char *name, dirname[256]; + char *name, *p, dirname[256]; char sep; int n; @@ -74,14 +74,20 @@ static PyObject *M_sys_dirname (PyObject *self, PyObject *args) sep = PyString_AsString(c)[0]; Py_DECREF(c); - n = strrchr(name, sep) - name; - if (n > 255) { - PyErr_SetString(PyExc_RuntimeError, "path too long"); - return 0; - } + p = strrchr(name, sep); + + if (p) { + n = p - name; + + if (n > 255) { + PyErr_SetString(PyExc_RuntimeError, "path too long"); + return 0; + } - strncpy(dirname, name, n); - dirname[n] = 0; + strncpy(dirname, name, n); + dirname[n] = 0; + return Py_BuildValue("s", dirname); + } - return Py_BuildValue("s", dirname); + return Py_BuildValue("s", "."); /* XXX need to fix this? (is crossplatform?)*/ } |