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:
authorWillian Padovani Germano <wpgermano@gmail.com>2004-07-03 09:17:04 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2004-07-03 09:17:04 +0400
commit928282772051eadd29b26a43b4c217ebf06d0ba9 (patch)
tree36e2a9906ed924e962554df716d30f0ad1bce798 /source/blender/python/api2_2x/Sys.c
parent90d4f7a3c1f6f789df61f348f974813a260014f5 (diff)
New scripts:
- hotkeys, obdatacopier and renameobjectbyblock, all from Jean-Michel Soler (jms); - bevel_center by Loic Berthe, suggested for inclusion by jms; - doc_browser, by Daniel Dunbar (Zr) Thanks to them for the new contributions! (I included doc_browser at 'Misc' because only users interested in script writing would actually use it, but it could also be under 'Help'. Opinions?) BPython related: - Added scriptlink methods to object, lamp, camera and world. - Object: added object.makeTrack and object.clearTrack (old track method). - sys: made sys.exists(path) return 0 for not found; 1 for file, 2 for dir and -1 for neither. - doc updates and fixes. - made ONLOAD event work. G.f's SCENESCRIPT bit was being zeroed in set_app_data. - Blender: updated functions Load and Save to support the builtin importers and exporters besides .blend (dxf, videoscape, vrml 1.0, stl, ...) - Draw: added mouse wheel events. - Scene: added scene.play to play back animations (like ALT+A and SHIFT+ALT+A). Makes a good counter, too, when the 'win' attribute is set to a space that doesn't "animate". The scene.play() addition and the fix to ONLOAD scriptlinks is part of the work for a Blender demo mode. It already works, but I'll still add support for Radiosity calculations and fix a thing in main(): it executes onload scripts too early (BIF_Init), giving funny results in alt+a animations and renderings when firing up Blender. Loading after the program is up has no such problems. When I finish I'll post examples of demo mode scripts.
Diffstat (limited to 'source/blender/python/api2_2x/Sys.c')
-rw-r--r--source/blender/python/api2_2x/Sys.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c
index de6da24496f..39412fada16 100644
--- a/source/blender/python/api2_2x/Sys.c
+++ b/source/blender/python/api2_2x/Sys.c
@@ -33,6 +33,7 @@
#include <BLI_blenlib.h>
#include <PIL_time.h>
#include <Python.h>
+#include <sys/stat.h>
#include "gen_utils.h"
#include "modules.h"
@@ -92,7 +93,12 @@ Each successive call is garanteed to return values greater than or\n\
equal to the previous call.";
static char M_sys_exists_doc[] =
-"(path) - Return 1 if given pathname (file or dir) exists, 0 otherwise.";
+"(path) - Check if the given pathname exists.\n\
+The return value is as follows:\n\
+\t 0: path doesn't exist;\n\
+\t 1: path is an existing filename;\n\
+\t 2: path is an existing dirname;\n\
+\t-1: path exists but is neither a regular file nor a dir.";
/*****************************************************************************/
/* Python method structure definition for Blender.sys module: */
@@ -337,16 +343,20 @@ static PyObject *M_sys_time (PyObject *self)
static PyObject *M_sys_exists (PyObject *self, PyObject *args)
{
+ struct stat st;
char *fname = NULL;
- int i = 0;
+ int res = 0, i = -1;
if (!PyArg_ParseTuple(args, "s", &fname))
return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string (file path) argument");
+ "expected string (pathname) argument");
- i = BLI_exists(fname);
+ res = stat(fname, &st);
- if (i) return Py_BuildValue("i", 1); /* path was found */
+ if (res == -1) i = 0;
+ else if (S_ISREG(st.st_mode)) i = 1;
+ else if (S_ISDIR(st.st_mode)) i = 2;
+ /* i stays as -1 if path exists but is neither a regular file nor a dir */
- return Py_BuildValue("i", 0); /* path doesn't exist */
+ return Py_BuildValue("i", i);
}